I've successfully combined all csv files in a directory, however struggling with the ability to skip the first row (header) of each file. The error I currently get is " 'list' object is not an iterator". I have tried multiple approaches including not using the [open(thefile).read()], but still not able to get it working. Here is my code:
import glob
files = glob.glob( '*.csv' )
output="combined.csv"
with open(output, 'w' ) as result:
for thefile in files:
f = [open(thefile).read()]
next(f) ## this line is causing the error 'list' object is not an iterator
for line in f:
result.write( line )
message = 'file created'
print (message)