In this post there is a Python example to convert from csv to xls.
However, my file has more than 65536 rows so xls does not work. If I name the file xlsx it doesnt make a difference. Is there a Python package to convert to xlsx?
In this post there is a Python example to convert from csv to xls.
However, my file has more than 65536 rows so xls does not work. If I name the file xlsx it doesnt make a difference. Is there a Python package to convert to xlsx?
There is a simple way
Here's an example using xlsxwriter:
FYI, there is also a package called openpyxl, that can read/write Excel 2007 xlsx/xlsm files.
Hope that helps.
Adding an answer that exclusively uses the pandas library to read in a .csv file and save as a .xlsx file. This example makes use of
pandas.read_csv
(Link to docs) andpandas.dataframe.to_excel
(Link to docs).The fully reproducible example uses numpy to generate random numbers only, and this can be removed if you would like to use your own .csv file.
With my library
pyexcel
,you can do it in one command line:
Each csv will have its own sheet and the name will be their file name.
How I do it with openpyxl lib: