I want to csv.DictReader
to deduce the field names from the file. The docs say \"If the fieldnames parameter is omitted, the values in the first row of the
I used islice from itertools. My header was in the last line of a big preamble. I have passed preamble and used hederline for fieldnames:
with open(file, "r") as f:
'''Pass preamble'''
n = 0
for line in f.readlines():
n += 1
if 'same_field_name' in line: # line with field names was found
h = line.split(',')
break
f.close()
f = islice(open(i, "r"), n, None)
reader = csv.DictReader(f, fieldnames = h)