In this article, we will be dealing with the conversion of Excel (.xlsx) file into .csv. There are two formats mostly used in Excel :
- (*.xlsx) : Excel Microsoft Office Open XML Format Spreadsheet file.
- (*.xls) : Excel Spreadsheet (Excel 97-2003 workbook).
Let’s Consider a dataset of a shopping store having data about Customer Serial Number, Customer Name, Customer ID, and Product Cost stored in Excel file.
check all used files here.
Now, let’s see different ways to convert an Excel file into a CSV file :
Method 1: Convert Excel file to CSV file using the pandas library.
Pandas is an open-source software library built for data manipulation and analysis for Python programming language. It offers various functionality in terms of data structures and operations for manipulating numerical tables and time series. It can read, filter, and re-arrange small and large datasets and output them in a range of formats including Excel, JSON, CSV.
Method 2: Convert Excel file to CSV file using xlrd and CSV library.
xlrd is a library with the main purpose to read an excel file.
csv is a library with the main purpose to read and write a csv file.
Method 3: Convert Excel file to CSV file using openpyxl and CSV library.
openpyxl is a library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files.It was born from lack of existing library to read/write natively from Python the Office Open XML format.
- Convert CSV to Excel using Pandas in Python
- Create a GUI to convert CSV file into excel file using Python
- Python program to read CSV without CSV module
- Convert JSON to CSV in Python
- Convert CSV to HTML Table in Python
- Convert HTML table into CSV file in python
- Convert CSV to JSON using Python
- How to Convert an image to NumPy array and saveit to CSV file using Python?
- Convert Text File to CSV using Python Pandas
- Python | Convert an HTML table into excel
- Convert a NumPy array into a csv file
- Working with csv files in Python
- Python | Read csv using pandas.read_csv()
- Reading CSV files in Python
- Writing CSV files in Python
- Saving Text, JSON, and CSV to a File in Python
- Writing data from a Python List to CSV row-wise
- Load CSV data into List and Dictionary using Python
- Python - Save List to CSV
- Reading and Writing CSV Files in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.