Rob Renaud <rren...@google.com> added the comment: 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 <rep...@bugs.python.org> wrote: > > Skip Montanaro <s...@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 <rep...@bugs.python.org> > <http://bugs.python.org/issue1818> > _______________________________________ > _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1818> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com