string to list

Ian Kelly ian.g.kelly at gmail.com
Thu Jun 14 01:10:20 EDT 2012


On Wed, Jun 13, 2012 at 10:06 PM, Jose H. Martinez
<josehmartinezz at gmail.com> wrote:
> string.split(',') will give you an array.
>
> Example:
>
> 'AAA,"BBBB,CCCC,DDDD",EEE,FFF,GGG '.split(',')
>
> ['AAA', '"BBBB', 'CCCC', 'DDDD"', 'EEE', 'FFF', 'GGG']

But it incorrectly splits the quoted part.  A proper CSV parser (like
the csv module) should leave that part as a single string, even though
it contains commas.



More information about the Python-list mailing list