|
|
15鱼币
(1)大神们,想从一个csv文件中读入,每行输出成1个新的csv文件,在循环里实现的话可以用这个语句吗? result = open(out_filename, 'w')
文件名称顺序往下编的话,应该如何定义?比如想生成201.csv 202.csv 203.csv这样
(2)result.write('%s,%s,%f,%f,%f\n' %(str(row[0]), row[1].encode('gb2312'),float(row[2]),float(row[3]),float(row[4]),
float(row[5])))
这句有问题吗,错误提示:“TypeError: not all arguments converted during string formatting”
Python2.7
谢谢喔~~
|
最佳答案
查看完整内容
file=open('inputfile.csv','r')
count=200
for eachline in file:
f=open('%s.csv' %count,'w')
f.write(eachline)
f.close()
count+=1
file.close()
这样应该就可以了
|