Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

Simple csv read/write


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)

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

On Apr 24, 8:35 pm, John Machin <sjmac@lexicon.net> wrote:

My apologies to the rest of the list, issues with groups.google.com
cause the multiple posts.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc