使用python将多个csv转换为xls,数字存储为整数而不是文本
我正在编写一个脚本,将多个csv文件转换为xls文件,我这样做了,但我面临的问题是数字存储为文本,而不是数字(整数)。 请帮助我将数字存储为数字而不是文本 请帮我做同样的事情使用python将多个csv转换为xls,数字存储为整数而不是文本,python,xlwt,Python,Xlwt,我正在编写一个脚本,将多个csv文件转换为xls文件,我这样做了,但我面临的问题是数字存储为文本,而不是数字(整数)。 请帮助我将数字存储为数字而不是文本 请帮我做同样的事情 按照列出的代码,您将覆盖对以下对象的调用: sheet.write(i, index, int(each.strip())) 在你的街区尽头,用这一行: sheet.write(i, index, each, style) 下面标有***的那条线似乎在毁掉你的好作品: for row in re
按照列出的代码,您将覆盖对以下对象的调用:
sheet.write(i, index, int(each.strip()))
在你的街区尽头,用这一行:
sheet.write(i, index, each, style)
下面标有***的那条线似乎在毁掉你的好作品:
for row in reader:
for index, each in enumerate(row):
if i==0:
sheet.write(i, index, each, headerStyle)
elif i==1:
sheet.write(i, index, each, headerStyle)
else:
if i >= 2:
if each == ' ' or each == '':
each = 0
sheet.write(i, index, each, style)
else:
if index > 0:
sheet.write(i, index, int(each.strip()))
else:
sheet.write(i, index, each.strip(), style)
**sheet.write(i, index, each, style)**
for row in reader:
for index, each in enumerate(row):
if i==0:
sheet.write(i, index, each, headerStyle)
elif i==1:
sheet.write(i, index, each, headerStyle)
else:
if i >= 2:
if each == ' ' or each == '':
each = 0
sheet.write(i, index, each, style)
else:
if index > 0:
sheet.write(i, index, int(each.strip()))
else:
sheet.write(i, index, each.strip(), style)
**sheet.write(i, index, each, style)**