This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdwhitley
Recipients barry, jdwhitley, rhettinger, skip.montanaro
Date 2009-02-09.09:24:56
SpamBayes Score 8.10109e-09
Marked as misclassified No
Message-id <1234171502.28.0.373023500591.issue1818@psf.upfronthosting.co.za>
In-reply-to
Content
An implementation of a namedtuple reader and writer.

Created a writer for the case where user would like to specify
desired field names and default values on missing field names.

e.g.
mywriter = NamedTupleWriter(f, fieldnames=['f1', 'f2', 'f3'], 
                            restval='missing')

Nt = namedtuple('LessFields', 'f1 f3')
nt = Nt(f1='one', f2=2)

mywriter.writerow(nt) # writes one,missing,2

any thoughts on case where defined fieldname has a leading 
underscore? Should there be a flag to silently ignore? 

e.g. 
if self._ignore_underscores:
   fieldname = fieldname.lstrip('_')

Leading underscores may be present in an unsighted csv file,
additionally, spaces and other non alpha numeric characters pose 
a problem that does not affect the DictReader class. 

Cheers,
History
Date User Action Args
2009-02-09 09:25:03jdwhitleysetrecipients: + jdwhitley, skip.montanaro, barry, rhettinger
2009-02-09 09:25:02jdwhitleysetmessageid: <1234171502.28.0.373023500591.issue1818@psf.upfronthosting.co.za>
2009-02-09 09:25:00jdwhitleylinkissue1818 messages
2009-02-09 09:25:00jdwhitleycreate