Matthew Iversen <teh....@gmail.com> added the comment: Skip, you were arguing in another csv issue on a NamedTupleReader that the Reader and Writer should work in concert together.
Certainly, making this default functionality for DictWriter would definitely make it work more in concert with DictReader. A sample process of reading and writing might be: 1. DictReader reads in header names, reads in data 2. Pass in header names to DictWriter on init 3. DictWriter writes out modified data back to csv file (headers get written automatically or with a method call) 4. DictReader can now reader in the csv file automatically again with header names My feeling is, if DictReader can read in head names, why can't DictWriter write them back out again? Shouldn't there be a good amount of symmatry to their function/abilities? My feeling of how to implement this functionality would be to include a new init argument, say 'writeheader'. It's default would be True if you wanted to implement this new feature by default, or False if you wanted to keep it an option so that older scripts relying on the old functionality won't break immmediately. DictWriter would then write the header on the first call to writerow(s), or perhaps also with an explicit call to writeheader() say. I certainly am miffed by the fact that DictWriter cannot produce (normally) a csv file that DictReader can read in automatically. ---------- nosy: +ivo _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue1537721> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com