I'm new to python and try to comprehend how I can use the filter function on an csv.DictReader to filter rows from an csv file. filter() can be used on an "iterable" and as far as I understand the DictReader fits this definition.
However when I try
f = open('file1.csv', 'r')
dialect = csv.Sniffer().sniff(f.read(1024))
f.seek(0)
reader = csv.DictReader(f, None, None, None, dialect)
filteredReader = filter(None, reader) #None will be replaced with my function
for i in filteredReader:
print(i)
I get TypeError: normcase() argument must be str or bytes, not 'DictReader'
.
Please note, that I don't want to filter on the filepointer (e.g. here), but on parsed csv rows. Do you have an idea how to do that?