Author ivo
Recipients ed_abraham, ivo, skip.montanaro
Date 2009-04-19.04:10:24
SpamBayes Score 1.25494e-12
Marked as misclassified No
Message-id <1240114228.01.0.347680677608.issue1537721@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-04-19 04:10:28ivosetrecipients: + ivo, skip.montanaro, ed_abraham
2009-04-19 04:10:28ivosetmessageid: <1240114228.01.0.347680677608.issue1537721@psf.upfronthosting.co.za>
2009-04-19 04:10:26ivolinkissue1537721 messages
2009-04-19 04:10:24ivocreate