Jervis Whitley <jervi...@gmail.com> added the comment: 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, ---------- keywords: +patch nosy: +jdwhitley Added file: http://bugs.python.org/file12990/ntreader3.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1818> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com