Requirement: I have 69 csvs. Merge them on the basis of below condition:
Condition: If value in cell at header 'col7' = 1, append the corresponding row in new csv.
Can you please help me complete this piece of code?
Below is my code:
with open('merged.csv', 'a') as mergedFile:
for csv in glob('*.csv'):
if csv == 'merged.csv':
pass
else:
for line in os.listdir():
for eachFile in open(csv, 'r'):
# write further code here if header 'col7' value = 1
# write further code here to add the corresponding rows meeting condition
mergedFile.write(line)
If there is any way of doing this by pandas, most welcome.