[Tutor] Parse Problem [2]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Mon, 12 Aug 2002 09:39:10 -0700 (PDT)


On Mon, 12 Aug 2002 fleet@teachout.org wrote:

> Ok, I'll try to be less verbose.
>
> Given the strings 'xxxxx: xxxxx "xxx xxx"' and 'xxxxx: xxxxx "xxxxxxx"'
> If I use xx=split.string(string," ") I get xx[2] as "xxx in the first
> instance and "xxxxxxx" in the second.  I need to get "xxx xxx".  Ie, I
> need to get everything within the quotes as xx[2].

Hi fleet,

Ah, so a simple string split doesn't work because it doesn't know what it
means to "quote" something.

You may want to use the CSV module for your program:

    http://www.object-craft.com.au/projects/csv/

It's supposed to handle quotes, and you can set the splitting character to
tab by doing something like this:

###
p = csv.parser(field_sep='\t')
###


Good luck!