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

Popular posts from this blog

Book review : Complete Guide to Standard C++ Algorithms

Multiplication table in html with python

Differences between references and pointers in C++ with use cases