excel - Python convert csv to xlsx -


in this post there python example convert csv xls.

however, file has more 65536 rows xls not work. if name file xlsx doesnt make difference. there python package convert xlsx?

here's example using xlsxwriter:

import os import glob import csv xlsxwriter.workbook import workbook   csvfile in glob.glob(os.path.join('.', '*.csv')):     workbook = workbook(csvfile[:-4] + '.xlsx')     worksheet = workbook.add_worksheet()     open(csvfile, 'rt', encoding='utf8') f:         reader = csv.reader(f)         r, row in enumerate(reader):             c, col in enumerate(row):                 worksheet.write(r, c, col)     workbook.close() 

fyi, there package called openpyxl, can read/write excel 2007 xlsx/xlsm files.

hope helps.


Comments