Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 30, 2023 17:11
Show Gist options
  • Save aspose-com-gists/01d71bf3cafec445f7ea46625a5dbaa3 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/01d71bf3cafec445f7ea46625a5dbaa3 to your computer and use it in GitHub Desktop.
Convert CSV to Excel and Excel to CSV in Python
import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, LoadOptions, SaveFormat
# Create CSV LoadOptions object
loadOptions = LoadOptions(FileFormatType.CSV)
# Create a Workbook object with CSV file's path and the loadOptions
workbook = Workbook("data.csv", loadOptions)
# Save CSV as XLSX
workbook.save("CsvToExcel.xlsx" , SaveFormat.XLSX)
import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, SaveFormat
# Create a Workbook object with Excel file's path
workbook = Workbook("data.xlsx")
# Save XLSX as CSV
workbook.save("ExcelToCSV.csv" , SaveFormat.CSV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment