I'm trying to export a list of strings to csv using comma as a separator. Each of the fields may contain a comma. What I obtain after writing to a csv file is that every comma is treated as a separator.
My question is: is it possible to ignore the commas (as separators) in each field?
Here is what I'm trying, as an example.
import csv
outFile = "output.csv"
f = open(outFile, "w")
row = ['hello, world' , '43333' , '44141']
with open(outFile, 'w') as writeFile:
writer = csv.writer(writeFile)
writer.writerow(row)
writeFile.close()
The output looks like this: outputObtained
What I would like is something like this: outputExpected
I think a way to solve this would be to use a different separator, as I read in some sites. But my question is if there is a way to solve this using comma (',') separators.
Thanks
"hello, world"
to preserve the embedded comma. The problem is with the process that reads the csv file to produce the spreadsheet in the image, which you haven't shown us. – Telephonyquoting=csv.QUOTE_ALL
– Dara