anyone can help with below?
(shlex.split
or re
could work, but no idea why codes below won't work)
s = 'hello, world, a, "b,c", d'
list(csv.reader([s]))[0]
# ['hello', ' world', ' a', ' "b', 'c"', ' d'] - get this
# ['hello', ' world', ' a', 'b,c', ' d'] - i want this
For the exact sample data you showed us, using
re.split
on the pattern,\s+
would work:This answer hinges on that the CSV data contained inside double quotes would not have any whitespace along with the comma separator.