split string but ignore sep inside double quotes

Tim Golden mail at timgolden.me.uk
Wed Apr 13 11:04:27 EDT 2011


On 13/04/2011 15:59, Jonno wrote:
> I have the following unicode object:
> u'3,"Some, text",more text'
>
> and I want to split it into a list like this:
> [3,"Some, text", more text]
>
> In other words I want to split on the comma but not if it's inside a
> double-quote.

You want the csv module which is designed for *exactly* this
form of data.

TJG



More information about the Python-list mailing list