Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active March 29, 2022 02:31
Code to Convert Excel to CSV in Python. Refer to this link for more details: https://kb.aspose.com/cells/python/how-to-convert-excel-to-csv-in-python/
import jpype
import asposecells
# Start JVM
jpype.startJVM()
from asposecells.api import License, Workbook, TxtSaveOptions
# Load License
licenseHtmlToImage = License()
licenseHtmlToImage.setLicense("Aspose.Cells.lic")
# Load the source XLSX file to convert to CSV in Python
workbook = Workbook("SourceExcelFile.xlsx")
# Create and Initialize TxtSaveOptions to customize CSV file
save_options = TxtSaveOptions()
# Set the flag to render separators for each blank row in the source Excel file
save_options.setKeepSeparatorsForBlankRow(True)
# Save the output Excel file as a CSV file
workbook.save("ExcelBookToCSV.csv",save_options)
# Shutdown the JVM
jpype.shutdownJVM()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment