split CSV fields

Fredrik Lundh fredrik at pythonware.com
Thu Nov 16 05:25:07 EST 2006


robert wrote:

> What is a most simple expression for splitting a CSV line
 > with "-protected fields?
> 
> s='"123","a,b,\"c\"",5.640'

import csv

the preferred way is to read the file using that module.  if you insist 
on processing a single line, you can do

     cols = list(csv.reader([string]))

</F>




More information about the Python-list mailing list