Reading CSV files and rewriting them without certain rows Python
I am new to programming. I have hundreds of CSV files in a folder and
certain files have the letters DIF in the second column. I want to rewrite
the CSV files without those lines in them. I have attempted doing that for
one file and have put my attempt below. I need also need help getting the
program to do that dfor all the files in my directory. Any help would be
appreciated.
Thank you
import csv
reader=csv.reader(open("40_5.csv","r"))
for row in reader:
if row[1] == 'DIF':
csv.writer(open('40_5N.csv', 'w')).writerow(row)
No comments:
Post a Comment