Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

saving to a .csv file

In my computations I got a list of strings:

vect = ['00011', '00010', '01011', '01111', '01100']

I need to save it as .csv file, each element row by row, ideally like this:

00011
00010
01011
01111
01100

I use a code:

import csv
C = vect
with open('file_path_vec.csv', 'w') as f:
      c = csv.writer(f)
      c.writerows(C)

But what I get in my .csv looks like this:

0,0,0,1,1
0,0,0,1,0
0,1,0,1,1
0,1,1,1,1
0,1,1,0,0

Why does it add commas in between? How can I get rid of them?