Excel to CSV

Convert Excel to CSV | Learn how to Convert XSLX to CSV

In this article, we are about to discuss the details of how to convert Excel to CSV using Python SDK. We understand that excel files are widely used to organize data, perform financial analysis, data entry, data management, accounting, charting & graphing, etc. However, for importing and exporting data, we rely upon comma-separated values (CSV) files. It’s one of the ways to exchange structured information through a simple text file. In this article, we are using programming SDK for conversion purposes as it supports single as well as bulk conversion operations.

Excel Conversion API

Aspose.Cells Cloud SDK for Python provides the feature to load popular excel formats (XLSX, XLS, ODS, XLSB, etc) and save the output in CSV format. It’s a wrapper around Aspose.Cells Cloud REST API empowers you to implement Excel processing features in Python applications. Please execute the following command in the terminal application to install the SDK:

pip install asposecellscloud

The next step is to create an Aspose Cloud account and obtain client credential details.

Convert Excel to CSV in Python

In this example, we are going to export 2nd worksheet in Excel workbook to CSV format. The Excel workbook needs to be already uploaded to cloud storage and after the conversion, the resultant CSV will also be stored in cloud storage.

  • First, we need to create an object of CellsApi while passing client credentials as arguments
  • Secondly, create a string object defining ouptut format as CSV
  • Finally, call cells_workbook_get_workbook(…) method to convert XLSX file to CSV format
Excel to CSV conversion preview

Image 1:- Excel to CSV conversion preview

The input excel file used in the above example can be downloaded from TestCase.xlsx and Converted.csv.

ODS to CSV Conversion using cURL Commands

The .ods is an extension of OpenDocument Spreadsheet Document format and Aspose.Cells Cloud also handles this format. So in this section, we are going to convert the selected ODS worksheet to CSV format using the cURL commands. The first step is to generate a JWT access token, so please execute the following command:

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=88d1cda8-b12c-4a80-b1ad-c85ac483c5c5&client_secret=406b404b2df649611e508bbcfcd2a77f" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now execute the following command to convert the worksheet named Sheet1 and save the content in CSV format.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/Input.ods/worksheets/Sheet1?format=CSV&verticalResolution=0&horizontalResolution=0" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-o output.csv
ODS to CSV conversion preview

Image 2:- ODS to CSV conversion preview.


In this article, we have discussed the steps on how to convert Excel to CSV using Python SDK. At the same time, we have also explored the details of how we can convert selected worksheets of ODS files to CSV format using the cURL command. We also recommend exploring the Programmers Guide to learn more about other exciting features of the API.

Nonetheless, you may consider downloading the complete source code of Python SDK from GitHub and updating it as per your requirements.