I have multiple csv files with date as filename (20080101.csv to 20111031.csv) in a folder. The csv files have common headers. The csv file looks like this:
You could read in each file at a time. Read it line by line
files = ['20080101.csv', '20080102.csv', '20080103.csv'] #...etc
for f in files:
file = open(f, 'r')
for line in file:
ray = line.split(';')
if (ray[0].strip() == '1' and ray[1].strip() == '2'):
fout = open('output.csv', 'a')
fout.write(ray[0].strip() + ' ; ' + ray[1].strip() + ' ; ' + ray[2].strip() + ' ; ' + f + '\n')
fout.close()
file.close()
Tested and works. May need some slight modifications.