CSV Issue

R

Rohan

I'm having a trouble consider this

import csv
f = open("/home/t/tp/va/some7.csv", "rb")
reader =csv.reader(f)
rows =[]
for row in reader:
rows.append(row)



rows[1].append('1')

print rows
f = open("/home/t/tp/va/e7.csv", "ab")
writer =csv.writer(f)

writer.writerows(rows)
f.close()

In the file some7.csv there is already some data like this
1
2
3
4
Now i'm trying to add a '1' in row2 so that data can be like this
1
2,1
3
4
Instead i'm getting like this
1
2
3
4
1
2,1
3
4

can some one explain this and how to get it in the way i want it/
 
R

Rohan

a means Append -- you are appending the data that you expect to the
EXISTING contents of the file.

Hello John,
Yea silly mistake, write mode will do.
thanks
 

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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top