Message82812
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 <report@bugs.python.org> wrote:
>
> Skip Montanaro <skip@pobox.com> 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 <report@bugs.python.org>
> <http://bugs.python.org/issue1818>
> _______________________________________
> |
|
Date |
User |
Action |
Args |
2009-02-27 02:16:56 | rrenaud | set | recipients:
+ rrenaud, skip.montanaro, barry, rhettinger, jdwhitley |
2009-02-27 02:16:55 | rrenaud | link | issue1818 messages |
2009-02-27 02:16:54 | rrenaud | create | |
|