How to quickly parse a list of strings
Posted
by math
on Stack Overflow
See other posts from Stack Overflow
or by math
Published on 2008-12-01T13:51:42Z
Indexed on
2010/04/30
16:07 UTC
Read the original article
Hit count: 170
python
If I want to split a list of words separated by a delimiter character, I can use
>>> 'abc,foo,bar'.split(',')
['abc', 'foo', 'bar']
But how to easily and quickly do the same thing if I also want to handle quoted-strings which can contain the delimiter character ?
In: 'abc,"a string, with a comma","another, one"'
Out: ['abc', 'a string, with a comma', 'another, one']
Related question: How can i parse a comma delimited string into a list (caveat)?
© Stack Overflow or respective owner