Simple csv read/write
Drew
olsonas at gmail.com
Thu Apr 26 11:32:40 EDT 2007
On Apr 24, 8:35 pm, John Machin <sjmac... at lexicon.net> wrote:
> On 25/04/2007 8:27 AM, Drew wrote:
>
> > Ok, I'm trying to do the simplest read/write from one csv file to
> > another. For some reason, every other row on the output file is a
> > blank row. What am I doing wrong?
>
> > import csv
>
> > reader = csv.reader(open('current.csv'))
> > writer = csv.writer(open('new.csv','w'))
>
> > for line in reader:
> > writer.writerow(line)
>
> 1. Try reading the responses already posted to your previous questions.
>
> 2. Try reading the documentation; for each of csv.reader and csv.writer,
> it says "If csvfile is a file object, it must be opened with the 'b'
> flag on platforms where that makes a difference."
My apologies to the rest of the list, issues with groups.google.com
cause the multiple posts.
More information about the Python-list
mailing list