Michael Hoffman wrote:
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.

Python 2.4 makes the fieldnames paramter optional:
"If the fieldnames parameter is omitted, the values in the first row of the csvfile will be used as the fieldnames."


i.e. the following should work fine in 2.4:

for row in csv.DictReader(file(filename)):
  print sorted(row.items())

Cheers,
Nick.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to