splitting a long string into a list

ronrsr ronrsr at gmail.com
Tue Nov 28 02:23:57 EST 2006


still having a heckuva time with this.

here's where it stand - the split function doesn't seem to work the way
i expect it to.


longkw1,type(longkw):   Agricultural subsidies; Foreign
aid;Agriculture; Sustainable Agriculture - Support; Organic
Agriculture; Pesticides, US, Childhood Development, Birth Defects;
<type 'list'> 1

longkw.replace(',',';')

Agricultural subsidies; Foreign aid;Agriculture; Sustainable
Agriculture - Support; Organic Agriculture; Pesticides, US, Childhood
Development


 kw = longkw.split("; ,")    #kw is now a list of len 1

kw,typekw= ['Agricultural subsidies; Foreign aid;Agriculture;
Sustainable Agriculture - Support; Organic Agriculture; Pesticides, US,
Childhood Development, Birth Defects; Toxic Chemicals;Antibiotics,
Animals;Agricultural Subsidies


what I would like is to break the string into a list of the delimited
words, but have had no luck doing that - I thought split wuld do that,
but it doens't.

bests,

-rsr-


Robert Kern wrote:
> ronrsr wrote:
> > I have a single long string - I'd like to split it into a list of
> > unique keywords. Sadly, the database wasn't designed to do this, so I
> > must do this in Python - I'm having some trouble using the .split()
> > function, it doesn't seem to do what I want it to - any ideas?
>
> Did you follow the recommendations given to you the last time you asked this
> question? What did you try? What results do you want to get?
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco




More information about the Python-list mailing list