我收到了这个错误:
Traceback (most recent call last): File "C:\Users\Office\Documents\Development\CSV-XLS.py", line 12, in for rowi, row in enumerate(g): _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
我在这里读到了一些关于文本模式文件的内容,但无法做出正面或反面的内容。 非常感谢任何帮助!
import sys, csv, xlwt
files = [r'C:\Users\Office\Downloads\TEST.csv']
for i in files:
f = open(i, 'rb')
g = csv.reader((f), delimiter=";")
workbook = xlwt.Workbook()
sheet = xlwt.Workbook()
sheet = workbook.add_sheet("Sheet 1")
for rowi, row in enumerate(g):
for coli, value in enumerate(row):
sheet.write(rowi, coli, value)
workbook.save(i + ".xls")