I wrote a python script in which I generate a csv from numbers I computed.
The rows I write are:
writeRow = [str(t), len(c) , {k for k in c.keys()}, {k for k in c.values()}]
I have two problems:
tis a number that can begin by 0. But in that case, the 0 is deleted. I tried withoutstr()but it doesn't change...the sets are printed as sets in the cells. However, I want to write these numbers separated by commas in the same cell and without the
{}How can I do that?
edit
I am using the csv module; In the code, I create lists for each row to write and then write them with csv.writerow
I'm gonna post more code:
from csv import reader, writer
with open(fileName1) as inp, open(fileName2,'w') as o:
I then define the reader, writer, and the variables t,c
writeRow = [str(t), len(c) , {k for k in c.keys()}, {k for k in c.values()}]
Then I write the result in the output file
Edit form of t and what a row should look like
t = 023 t = 123 t is an int
The line in the end should look like:
cell1 cell2 cell3 cell4
123 2 string1,string2 num1,num2
string1 and str2 are the dict keys; num1,num2 the corresponding values
len(c)) for each row? CSV does not fit very well otherwise.tcan begin with zero?type(t)? Is it astrthat represents a number? Is076supposed to be octal?076 == 62.