[Python-ideas] csv.DictReader could handle headers more intelligently.
Mark Hackett
mark.hackett at metoffice.gov.uk
Mon Jan 28 13:21:19 CET 2013
On Friday 25 Jan 2013, rurpy at yahoo.com wrote:
>
> The csv DictReader *uses* a dictionary for its output. That
> it does so imposes no requirements on how it should parse or
> otherwise handle the input that eventually goes into that
> dict.
And that doesn't mean that writing
dict[A]=1
dict[A]=9
results in dict[A] being a list containing 1 and 9.
A program using a dictionary entry has to know whether the input has duplicate
headers because in the case where only the first line is done, writing out the
value of dict[A] gives you "1". Writing out dict[A] if it's a list gives you
"[1,9]" which must be parsed differently.
More information about the Python-ideas
mailing list