I am trying to write an array to a csv but if the array cell has double quotes in it, it adds quotes like so:
example data in the array: The quick brown "fox" jumps
that same data in the csv: "The quick brown ""fox"" jumps"
If the first part is in quotes like so: "The quick" brown fox jumps, it does the same thing: """The quick"" brown fox jumps". So it is adding quotes around the part that has quotes and then adds quotes around the entire cell contents.
Here is my code that writes to the csv:
matrix = populateArray()
with open('phrases.csv', 'w', encoding='utf-8', newline='') as f:
thewriter = csv.writer(f)
for x in range(0,1):
print(matrix[x])
thewriter.writerow(matrix[x])
The output of print(matrix[x]) is:
['The "quick" brown fox jumps', 'Lorem ipsum']
So you can see the data is formatted properly directly before it gets written to the csv, but at some point during the actual writing of the csv, it adds the extra quotes as described above.
Any help is much appreciated. Thanks