classification
Title: Add named tuple reader to CSV module
Type:
Components: Library (Lib) Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, rhettinger, skip.montanaro
Priority: Keywords:

Created on 2008-01-13 22:27 by rhettinger, last changed 2008-01-22 20:12 by skip.montanaro.

Files
File name Uploaded Description Edit Remove
ntreader.diff rhettinger, 2008-01-13 22:27 Proof-of-concept patch
Messages
msg59866 (view) Author: Raymond Hettinger (rhettinger) Date: 2008-01-13 22:27
Here's a proof-of-concept patch.  If approved, will change from
generator form to match the other readers and will add a test suite.

The idea corresponds to what is currently done by the dict reader but
returns a space and time efficient named tuple instead of a dict.  Field
order is preserved and named attribute access is supported.

A writer is not needed because named tuples can be feed into the
existing writer just like regular tuples.
msg61523 (view) Author: Raymond Hettinger (rhettinger) Date: 2008-01-22 19:25
Barry, any thoughts on this?
msg61532 (view) Author: Skip Montanaro (skip.montanaro) Date: 2008-01-22 20:12
I'd personally be kind of surprised if Barry had any thoughts on this.
Is there any reason this couldn't be pushed down into the C code and
replace the normal tuple output completely?  In the absence of any
fieldnames you could just dream some up, like "field001", "field002",
etc.

Skip
History
Date User Action Args
2008-01-22 20:12:41skip.montanarosetnosy: + skip.montanaro
messages: + msg61532
2008-01-22 19:25:56rhettingersetmessages: + msg61523
2008-01-13 22:27:14rhettingercreate