473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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)

Apr 24 '07 #1
2 1991
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."
Apr 25 '07 #2
On Apr 24, 8:35 pm, John Machin <sjmac...@lexicon.netwrote:
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.

Apr 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fabrice Cavarretta | last post by:
I am using a specialized database software (for bibliography: EndNote) that does export in XML. I would like to be able to read that into a simple software, like Excel or Access, in order to do...
1
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that...
1
by: Kenny ODell | last post by:
I am struggling a bit with XML, even as I wade through endless help files and several books. I thought it would be useful to toss my particular needs to the group to see what you think is the best...
0
by: Daniel Sélen Secches | last post by:
I found a good class to do a simple FTP. Very good.... I'm posting it with the message, i hope it helps someone ============================================================== Imports...
0
by: Harley | last post by:
Hello, I am just learning the tcp/ip functions etc under vb.net so please look over me if this is obviouse. I have been all over looking into any functions that I didn't totaly understand and...
11
by: Sehboo | last post by:
Hi, I want to write a very very simple mail application which my father can use (maybe then I will be able to send and receive emails from him). This application will have a text box, where he...
2
by: iwdu15 | last post by:
hey, i was wondering if 1) anyone could tell me whats wrong with my code, i did a little fixing to the msdn version fo this, or 2) how to make a simple program that will connect and listen for...
0
by: rich | last post by:
Hi all, I have a fairly complex "feed" application that recieves messages from an external user-supplied API via a callback function, and attempts to forward these messages to another...
5
by: newsaboutgod | last post by:
I think VB.NET drives some people crazy because some simple VB6 things seem so hard. Here is some VB6 code: 'Write CSV File open "c:\test.csv" for output as #1 write#1, "1","2","3","4","5"...
1
by: jerry | last post by:
i have written a simple phonebook program,i'll show you some of the codes,the program's head file is member.h . i suppose the head file works well.so i don't post it. here's the clips of main...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.