I have somes csvs where the fields names are on the third line. The two first line are comment and the true csv start at the third line.
What is the best way to use csv.DictReader to start at the third line not the first line ?
Regards
I have somes csvs where the fields names are on the third line. The two first line are comment and the true csv start at the third line.
What is the best way to use csv.DictReader to start at the third line not the first line ?
Regards
you can call next(f)
twice (where f is the file handler) and then pass it to csv.DcitReader() constructor, e.g:
import csv
with open('so.csv') as f:
next(f)
next(f)
dict_rdr = csv.DictReader(f)
for line in dict_rdr:
print(line)