Thanks for everyone's help.
Though Bjoernke's solution looks clever, I could not get it to work.
I ended up with this ugly thing:
function turnIntoArray p
put line 1 of p into tHeaders
set the itemDelimiter to tab
repeat with x = 2 to the number of lines in p
repeat with y = 1 to the number of items in tHeaders
put item y of line x of p into a[x][item y of tHeaders]
end repeat
end repeat
return a
end turnIntoArray
On Apr 9, 2010, at 8:56 AM, Björnke von Gierke wrote:
> That the split and combines are useless is completely wrong. I use them all
> the time and it's a huge timesaver for manipulating x,y matrices. Of course,
> for the given Task, they do not work for what you want directly. You'll need
> to change the orientation first, for example thusly:
>
> on mouseUp
> --assuming the example colour and food data from below
> put field 1 into theData
> split theData by column
> repeat with theKey = 1 to the number of lines in the keys of theData
> replace return with tab in theData[theKey]
> end repeat
> combine theData by return
> split theData by return and tab
> put the keys of theData --all done
> end mouseUp
>
> Of course a single line solution for switching the orientation of tables
> would be most handily, because this is really arcane. I'm sure there's other
> ways that are faster, especially when you only use "repeat for each line in
> theData" in combination with "put after <endResult>", but you asked about
> combine and split ;)
>
> Bjoernke
>
> On 9 Apr 2010, at 17:13, Bob Sneidar wrote:
>
>> Just had a few rounds with split and combine, and they are not what you
>> think they are. Split takes the first value in a delimited line and that
>> becomes the key. The rest of the items become the elements. The commands are
>> fairly useless for much of anything.
>>
>> Bob
>>
>>
>> On Apr 9, 2010, at 12:07 AM, Josh Mellicker wrote:
>>
>>> Given a variable like this, where the first line is "headers":
>>>
>>> name [tab] color [tab] food
>>> Trevor [tab] green [tab] salad
>>> Sarah [tab] blue [tab] pizza
>>> Richard [tab] orange [tab] burgers
>>> David [tab] purple [tab] fruit
>>>
>>> What is the best way to turn this into an array, where the array keys are
>>> the first line of the variable?
>>>
>>> I have tried various forms of "split by" ""split using" and ""split with"
>>> but haven't found the right formula. Personally I find the documentation on
>>> the various forms of the "split" and "combine" commands a bit scant.
>
>
> --
>
> official ChatRev page:
> http://bjoernke.com?target=chatrev
>
> Chat with other RunRev developers:
> go stack URL "http://bjoernke.com/chatrev/chatrev1.3b3.rev"
>
> _______________________________________________
> use-revolution mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution