Split a string by commas with quote characters using csv.Reader in Python
import csv
lines = ['2,main,"valid,house",B2', 'and, more, "stuff"']
for row in csv.reader(lines, delimiter=",",quotechar='"'):
print(row)
Output:
['2', 'main', 'valid,house', 'B2']
['and', ' more', ' "stuff"']
Comments
Post a Comment