Simple csv read/write

D

Drew

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)
 
J

John Machin

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."
 
D

Drew

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top