string to list

Jose H. Martinez josehmartinezz at gmail.com
Thu Jun 14 00:06:50 EDT 2012


string.split(',') will give you an array.

Example:

'AAA,"BBBB,CCCC,DDDD",EEE,FFF,GGG '.split(',')

['AAA', '"BBBB', 'CCCC', 'DDDD"', 'EEE', 'FFF', 'GGG']

On Wed, Jun 13, 2012 at 10:53 PM, Chris Rebert <clp2 at rebertia.com> wrote:

> n Wed, Jun 13, 2012 at 7:29 PM, bruce g <bruceg113355 at gmail.com> wrote:
> > What is the best way to parse a CSV string to a list?
>
> Use the `csv` module:
> http://docs.python.org/library/csv.html
> http://www.doughellmann.com/PyMOTW/csv/
>
> The `StringIO` module can be used to wrap your string as a file-like
> object for consumption by the `csv` module:
> http://docs.python.org/library/stringio.html
>
> Cheers,
> Chris
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120614/412058ac/attachment.html>


More information about the Python-list mailing list