Hi,
I use the following line to write some information to a CSV file which is comma 
delimited.

f = open(output_file, 'w', newline='')
wr = csv.writer(f)
...
f.write(str(n) + "," + str(key) + "\n" )


Problem is that key is a string which may contain ',' and this causes the final 
CSV file to have more than 2 columns, while I want to write the whole key as a 
single column.

I know that wr.writerow([key]) writes the entire key in one column, but I would 
like to do the same with write(). Any idea to fix that?


Regards,
Mahmood
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to