[issue1818] Add named tuple reader to CSV module

Skip Montanaro report at bugs.python.org
Fri Feb 27 02:00:25 CET 2009


Skip Montanaro <skip at 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 at bugs.python.org>
<http://bugs.python.org/issue1818>
_______________________________________


More information about the Python-bugs-list mailing list