extract by delimiter
Nonsanity
rev at nonsanity.com
Tue Dec 28 19:00:29 EST 2010
If that's the block of text you have to work with, set itemdel to quote and
use the odd items (delete last char) for the keys of an array, and the even
items as the values.
set itemdel to quote
repeat with a = 1 to the number of items in mydata step 2
put word 1 to -1 of item a of mydata into thekey
delete last char of thekey
put item a+1 of mydata into myarray[ thekey ]
end repeat
This code doesn't handle the keys that are the same, but it should give you
the idea.
~ Chris Innanen
~ Nonsanity
On Tue, Dec 28, 2010 at 5:58 PM, Thomas McGrath III <mcgrath3 at mac.com>wrote:
> I am stuck. I've been trying to extract text from an RSS feed and so far I
> have the information I need but am stuck at extracting it into a better
> format. Here is what I have so far:
>
> location city="Bethel Park" region="PA" country="United States"
> units temperature="F" distance="mi" pressure="in" speed="mph"
> wind chill="21" direction="250" speed="10"
> atmosphere humidity="51" visibility="10" pressure="30.04" rising="1"
> astronomy sunrise="7:39 am" sunset="4:58 pm"
> condition text="Cloudy" code="26" temp="30" date="Tue, 28 Dec 2010 4:52
> pm EST"
> forecast day="Tue" date="28 Dec 2010" low="22" high="30" text="Mostly
> Cloudy" code="27"
> forecast day="Wed" date="29 Dec 2010" low="25" high="32" text="Mostly
> Cloudy" code="28"
>
> I can't delimit with space as "location city" has a space in it.
> I can't use = because then I get " "Bethel Park" region" instead of just
> "Bethel Park"
>
> I am trying to figure out how to exclude items in between " " and then
> replace space with "_" and then use space to delimit.
>
> Any ideas on how to exclude between " "s ?
>
> Thanks for your help,
>
> -- Tom McGrath III
> http://lazyriver.on-rev.com
> 3mcgrath at comcast.net
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list