Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/0a5cd10d0f54367efaedc7ae1876cae0 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/0a5cd10d0f54367efaedc7ae1876cae0 to your computer and use it in GitHub Desktop.
Convert XLSX to CSV using Python
import aspose.cells
from aspose.cells import Workbook, SaveFormat
def convert_xlsx_to_csv(input_file: str, output_file: str):
try:
# Load the XLSX workbook
workbook = Workbook(input_file)
# Save the first worksheet as CSV
workbook.save(output_file, SaveFormat.CSV)
print(f"Conversion successful: {output_file}")
except Exception as e:
print(f"Error during conversion: {e}")
if __name__ == "__main__":
input_path = "Data/sample.xlsx"
output_path = "output/sample.csv"
convert_xlsx_to_csv(input_path, output_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment