I have a list of lists in python that represents data to be written in a csv file. My code for that is :
for n, d, p in zip(names, dates, posts):
writer.writerow([i, n, d, p])
However, some of the strings in posts contain semicolons, and this creates new cells in the csv. I've looked online and tried
- setting quoting=csv.QUOTE_ALL
- wrapping each post string inside double quotes
- wrapping the semicolons inside double quotes
- using normal python write instead of csv.writer
Nothing's worked so far. Any help, every online answer to escaping comma's I've found involves (1) or (2) which doesn't work for me. Please help!
Edit: Here's an example of what I mean
When I write the row ['a', 'b', 'c', 'd;e'], the d and e get put into different cells, like:
a | b | c | d | e
As opposed to what I want, which is:
a | b | c | d;e