everybody. I am currently working to merge the csv files. For example, you have files from filename1 to filename100. I used the following code to combine 100 files and the following error occurred: I'll put the code up first. import 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()
And the following error occurred when the above file was executed:
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'
I've been working on it for a few days, and I don't know what to do.
f.next
would work in Python 2; in Python 3next
is spelled__next__
. The built-in functionnext
will work on both. – user4815162342 Sep 2 '18 at 7:23