大家。我目前正在合并 csv 文件。例如,您有从 filename1 到 filename100 的文件。我用下面的代码合并了100个文件,出现如下错误:我先把代码放上去。导入 csv
fout=open("aossut.csv","a")
# first file:
for line in open("filename1.csv"):
fout.write(line)
# now the rest:
for num in range(2,101):
f = open("filename"+str(num)+".csv")
f.next() # skip the header
for line in f:
fout.write(line)
f.close() # not really needed
fout.close()
并且在执行上述文件时出现以下错误:
File "C:/Users/Jangsu/AppData/Local/Programs/Python/Python36-32/tal.py", line 10, in
<module>
f.next() # skip the header
AttributeError: '_io.TextIOWrapper' object has no attribute 'next'
这几天我一直在努力,我不知道该怎么办。