Message81453
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, |
|
Date |
User |
Action |
Args |
2009-02-09 09:25:03 | jdwhitley | set | recipients:
+ jdwhitley, skip.montanaro, barry, rhettinger |
2009-02-09 09:25:02 | jdwhitley | set | messageid: <1234171502.28.0.373023500591.issue1818@psf.upfronthosting.co.za> |
2009-02-09 09:25:00 | jdwhitley | link | issue1818 messages |
2009-02-09 09:25:00 | jdwhitley | create | |
|