[issue3436] csv.DictReader inconsistency
Nick Coghlan
report at bugs.python.org
Sun Jul 27 06:15:48 CEST 2008
Nick Coghlan <ncoghlan at gmail.com> added the comment:
Like Raymond, I have issues with the idea of implicitly reading the
headers in __init__, but would be fine with the idea of a separate
method in 2.7/3.1.
As far as working around the absence of such a method goes, I personally
use itertools.chain if I happen to need the headers before I start
iterating:
r = csv.DictReader(open('test.csv'))
first = next(r)
# Do something with r.fieldnames
for row in chain(first, r):
# Do something with each row
----------
nosy: +ncoghlan
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3436>
_______________________________________
More information about the Python-bugs-list
mailing list