Pythonic use of CSV module to skip headers?
Michael Hoffman
m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Sat Dec 4 06:18:27 EST 2004
Skip Montanaro wrote:
> Assuming the header line has descriptive titles, I prefer the DictReader
> class. Unfortunately, it requires you to specify the titles in its
> constructor. My usual idiom is the following:
I deal so much with tab-delimited CSV files that I found it useful to
create a subclass of csv.DictReader to deal with this, so I can just write:
for row in tabdelim.DictReader(file(filename)):
...
I think this is a lot easier than trying to remember this cumbersome
idiom every single time.
--
Michael Hoffman
More information about the Python-list
mailing list