Das Modul XlsxWriter mit pip install XlsxWriter installieren. Weitere Infos zum Lesen und Schreiben von CSV-Dateien hier.
import os import glob import csv from xlsxwriter.workbook import Workbook for csvfile in glob.glob(os.path.join('.', '*.csv')): print ("csvfile:", csvfile) workbook = Workbook(csvfile + '.xlsx') worksheet = workbook.add_worksheet() with open(csvfile, 'rt', encoding="ascii") as f: reader = csv.reader(f, \ delimiter=';', quotechar='"') for r, row in enumerate(reader): for c, col in enumerate(row): worksheet.write( r, c, col) workbook.close() |