How to convert Excel XLSX to CSV Files in Python

Document conversion is a snap with our convert API. Let’s look at how to apply it to converting an Excel file into a CSV.

First, we need to use pip installer to add our client:

pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.Convert.git

Call convert_document_xlsx_to_csv:

from __future__ import print_function
import time
import cloudmersive_convert_api_client
from cloudmersive_convert_api_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_convert_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Apikey'] = 'Bearer'
# create an instance of the API class
api_instance = cloudmersive_convert_api_client.ConvertDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/file' # file | Input file to perform the operation on.
try:
# Excel XLSX to CSV
api_response = api_instance.convert_document_xlsx_to_csv(input_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ConvertDocumentApi->convert_document_xlsx_to_csv: %s\n" % e)

Annnnnd we’re done! Our conversion API can be used for a much wider variety of file conversion and editing purposes, so be sure to check out our documentation for more info.

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store