how to append to a new row when writing to CSV file

Viewed 51624

I want to append to a new row in my CSV file when i write to it. Current CSV file look like this:

a,b,c
1,1,1

my code to append to CSV file:

with open('mycsvfile.csv','a') as f:
    writer=csv.writer(f)
    writer.writerow(['0','0','0'])

new mycsvfile:

a,b,c
1,1,1,0,0,0

What i want:

a,b,c
1,1,1
0,0,0
3 Answers
Related