Hi John,
The problem is that order in which your array keys are being returned to
you is not in any sort of sequence.
I'm not quite sure of your needs but if you want the data to come back in
alphabetical order then:
put the keys of counterArray into tKeys
sort tKeys
repeat for each line rKey in tKeys
<whatever you need to do>
end repeat
If you want the keys to come back in the order in which you encounter the
keywords, it gets a bit more complicated and you'll need to keep some sort
of index to the order of the items. Maybe something like this:
repeat for each item rItem in it
if lineOffset(rItem, tWords)=zero then
put rItem & return after tWords
end if
add 1 to counterArray[lineOffset(rItem, tWords)
end repeat
tWords will contain a list of the words in the order they were encountered
in your csv file
To get the data back:
repeat for each line rWord in tWords
put rWord,counterArray[lineOffset(rWord,tWords)] & return after
tWordCounts
end repeat
Is that something close to what you need?
Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
On Sun, Feb 9, 2014 at 8:35 AM, JOHN PATTEN <[email protected]> wrote:
> Thanks Stephen & Roger...
>
> I'm looking at the tutorial here:
> http://lessons.runrev.com/s/lessons/m/4071/l/11494-how-do-i-sort-an-array
>
> But I'm not getting my head around creating a index in order to keep the
> order of my elements straight. In my script, I thought I was creating an
> index out of the array?
> ...
> repeat with y = 1 to the number of items of it ## row spreadsheet data
> from Google Form
> put item y of it into counterArray[item y of it][y]
> ...
>
> I see how I can replace my comma deliminated data with tab delimitated
> data thanks to Richard's article Roger shared. It looks like LiveCode
> automagically orders the elements of the array it creates alphabetically?
> Is that correct? I'm guessing that is why my data is out of order?
>
> Thanks for the suggestions, but still not quite there yet :)
>
>
>
>
> On Feb 9, 2014, at 8:02 AM, Roger Eller <[email protected]>
> wrote:
>
> > I have used the csv function in Richard Gaskin's article, "CSV must die".
> > It works great on Google form data.
> >
> > http://www.fourthworld.com/embassy/articles/csv-must-die.html
> >
> > ~Roger
> > On Feb 9, 2014 12:12 AM, "JOHN PATTEN" <[email protected]> wrote:
> >
> >> Hi All,
> >> I'm trying to parse a Google Form csv data file. Each row in csv
> >> represents one completed form entry by a user. The Google Form (survey)
> >> allows for specific drop down selections. Here's some sample form csv
> data:
> >>
> >> End,End,End,Middle,
> >> Just right,Too loud,Too loud,Just right,
> >> No,Yes,No,No,
> >>
> >> I'm trying to use an array to pull out each item and the item counts.
> This
> >> is what I would like have reported out:
> >>
> >> End,3
> >> Middle,1
> >> Just right,2
> >> Too loud,2
> >> No,3
> >> Yes,1
> >>
> >> Myscript is working, but because I call the same array each time I loop
> >> through my reported out data is out of order. It looks like:
> >>
> >> Yes,1
> >> Just right,2
> >> No,3
> >> Too loud,2
> >> Middle,1
> >> End,3
> >>
> >> (Msg end of Part I)
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> [email protected]
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> > _______________________________________________
> > use-livecode mailing list
> > [email protected]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode