Why .csv file over .xlsx file?
- CSV is a format for saving table data in a separate text file with the extension .csv while Excel is a spreadsheet that stores files into a related format vls xls or xlsx.
- CSV is a plain text format with a comma-separated series and Excel is a binary file that stores information for all worksheets.
- CSV file cannot perform tasks on data while Excel can perform tasks on data.
- CSV files are faster and use less memory and Excel uses more memory while importing data.
- CSV files can be opened with any text editor in windows while Excel files can be opened by text editors.
For converting a .xlxs file to a .csv
- You need Python latest version installed in your laptop.
- You can get the latest Python file from https://www.python.org/downloads/
- Read your excel file using the xlrd module and then you can use the csv module to create your own new csv.
- Install the xlrd module in your command line.
- For installing xlrd module :
Command -> pip install xlrd
wb = xlrd.open_workbook('excel.xlsx')
sh = wb.sheet_by_name('Sheet1')
your_csv_file = open('your_csv_file.csv', 'w')
wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)
for rownum in range(sh.nrows):
# runs the csv_from_excel function:
You can convert any Xlsx sheet into CSV file using the above program by slightly changing the code according to your data. If you have any doubts regarding the article, mention them in the comment section.