This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rrenaud
Recipients barry, jdwhitley, rhettinger, rrenaud, skip.montanaro
Date 2009-02-27.02:16:54
SpamBayes Score 4.9154255e-07
Marked as misclassified No
Message-id <[email protected]>
In-reply-to <[email protected]>
Content
I did a search on Google code for the DictReader constructor.  I
analyzed the first 3 pages, the fieldnames parameter was used in 14 of
27 cases (discounting unittest code built into Python) and was not
used in 13 of 27 cases.  I suppose that means headered csv files are
sufficiently rare that they shouldn't be created implicitly by
default.  I still don't like the lack of symmetry of supporting
implicit header reads, but not implicit header writes.

On Thu, Feb 26, 2009 at 8:00 PM, Skip Montanaro <[email protected]> wrote:
>
> Skip Montanaro <[email protected]> added the comment:
>
> More concretely, I don't think this is so onerous:
>
>    names = ["col1", "col2", "color"]
>    writer = csv.DictWriter(open("f.csv", "wb"), fieldnames=names, ...)
>    writer.writerow(dict(zip(names, names)))
>    ...
>
> or
>
>    f = open("f.csv", "rb")
>    names = csv.reader(f).next()
>    reader = csv.DictReader(f, fieldnames=names, ...)
>    ...
>
> Skip
>
> _______________________________________
> Python tracker <[email protected]>
> <http://bugs.python.org/issue1818>
> _______________________________________
>
History
Date User Action Args
2009-02-27 02:16:56rrenaudsetrecipients: + rrenaud, skip.montanaro, barry, rhettinger, jdwhitley
2009-02-27 02:16:55rrenaudlinkissue1818 messages
2009-02-27 02:16:54rrenaudcreate