My current understanding of the quotechar parameter is that it surrounds the fields that are separated by a comma. I'm reading the csv documentation for python and have written a similar code to theirs as such:
import csv
with open("test.csv", newline="") as file:
reader = csv.reader(file, delimiter=",", quotechar="|")
for row in reader:
print(row)
My csv file contains the following:
|Hello|,|My|,|name|,|is|,|John|
The output gives a list of strings as expected:
['Hello', 'My', 'name', 'is', 'John']
The problem arises when I have whitespace in between the commas in my csv file. For example, if i have a whitespace after the closing | of a field like such:
|Hello| ,|My| ,|name| ,|is| ,|John|
It gives the same output as before but now there's a whitespace included in the strings in the list:
['Hello ', 'My ', 'name ', 'is ', 'John']
It was my understanding that the quotechar parameter would only consider what was between the | symbol. Any help is greatly appreciated!