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

Mark Hackett mark.hackett at metoffice.gov.uk
Tue Jan 29 13:35:01 CET 2013


On Tuesday 29 Jan 2013, Steven D'Aprano wrote:
> > If it dropped the columns and shouldn't have, then the results will be
> > seen to be wrong anyway, so there's not a huge amount of need for this.
> 
> You cannot assume that the caller knows that there are duplicated column
>  names
> 

You cannot assume they wanted them as a list.

You cannot assume that duplicate replacement is what they want.

If someone is using a csv file with header names they have never read, how are 
they going to use the data? They won't even know the name to access the value 
in the dictionary! So I discard the claim that the caller may not know the 
column names are duplicated. They have to know what the headers are to use 
DictReader.



More information about the Python-ideas mailing list