Using the function I wrote in Python 2, I was trying to concatenate csv files:
def concat_csv():
"""
A function to concatenate the previously wrangled csv files in current working dir
"""
with open('2017_oldnew.csv', 'a') as f_out:
# First file
with open('old.csv') as f_read:
for line in f_read:
f_out.write(line)
# Second file
with open('new.csv') as f_read:
f_read.next()
for line in f_read:
f_out.write(line)
However, running this Python 3 gives me an error message:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-110-a5a430e1b905> in <module>()
1 # Concatenate the files
----> 2 concat_csv()
<ipython-input-109-9a5ae77e9dd8> in concat_csv()
10 # Second file
11 with open('new.csv') as f_read:
---> 12 f_read.next()
13 for line in f_read:
14 f_out.write(line)
AttributeError: '_io.TextIOWrapper' object has no attribute 'next'