CSV has field that is being parsed which may or may not have entries within the field that have values that are additionally separated by comma.
import csv
def import_text(filename, separator):
for line in csv.reader(open(filename), delimiter=separator,
skipinitialspace=True):
if line[19]:
for elt in line[19].split(','):
yield elt
for data in import_text('filename.csv', ','):
print (data)
Using the script above, column 20 in a CSV will print the following:
a
b, c, d
e, f
I would instead like b, c, d; e, f to print on their own respective lines like so:
a
b
c
d
e
f
Split the column and yield fields individually: