[Python-ideas] csv.DictReader could handle headers more intelligently.

Steven D'Aprano steve at pearwood.info
Wed Jan 30 13:09:20 CET 2013


On 30/01/13 21:32, Mark Hackett wrote:

> If you don't know what's in the csv file at all, then how do you know what
> you're supposed to do with it.

Maybe you're processing the file without caring what the column names are,
but you still need to map column name to column contents. This is no more
unusual than processing a dict where you don't know the keys: you just iterate
over them.

Or maybe you're scanning the file for one specific column name, and you don't
care what the other names are.

Or, most likely, you know what you are *expecting* in the CSV file, but because
data files don't always contain what you expect, you want to be notified if
there is something unexpected rather than just have it silently do the wrong
thing.



-- 
Steven





More information about the Python-ideas mailing list