2

How can I split this up leaving the comma in quotes as one whole list item, I have tried to use the csv module, but can't work it out.

import csv
example = 'John, "30 Oak crescent, oakley", 30, car'
line = csv.reader(example)

print(line)

but the result is the memory address of the reader object, so I can't even explore the csv module as I can't get a list out of the object.

list(line)

separates line into a list of individual characters.

required outcome:

['John', '30 Oak crescent, oakley', 30, 'car']

There is an answer for this using python2, but not for python3 and I can't get it to translate.

iFunction
  • 981
  • 3
  • 15
  • 32
  • Ok, I have found the problem, and this is actually a duplicate of this question: https://stackoverflow.com/questions/8069975/split-string-on-commas-but-ignore-commas-within-double-quotes How do I delete the question of flag it as a duplicate please – iFunction Mar 27 '18 at 12:24

0 Answers0