Need to assistance unpacking a string
Hi happy weekend...
I'm still not fluent yet, brain still rewiring... but admiring scripts
So this project is one of a series of conversion, porting over scripts from google to apple. Reason being I like to slowing do it all in house in apple, to minimize export data to google processing and porting back results; besides I had to break it into chunks for google since it has a lower character limit than Apple Numbers.
Phase I
GOALS
- unpack Sheet 1 cell A1 string (or perhaps the entire column not limited to A1) in chunks of 3 to populate Sheet 2
- Count each occurrence of each group of three digit city codes LAX RDU YYZ e.t.c
- Lastly rank them in Sheet 3 account most repeated cities and the number first five ranks and the least repeat five ranks and count of occurrence. You should end up with ten cities
Phase II (not expecting to get this far due to complexity, I will be happy with the first phase )
Is to apply permutation to catch the occurrence disregarding the exact order. Reason to catch possible misspells. certain city share same letters only rearranged e.g ORD DOR JFK FKJ CDG LHR RHL
- Count occurrence using new criteria
- rank them
- save ranks to Sheet 4
That's basically the original js script did. I guess the main thing I would be loosing is the side bar with the menu that displays the results in addition to writing to the sheet.
My attempt not working, & incomplete too; looks like i'm far from setting it up. I've been tinkering a bit with it though.
-- Get the active sheet
tell front document of application "Numbers"
set sourceTable to table "Table 1" of sheet "Sheet 1"
set destTable to table "Table 1" of sheet "Sheet 2"
set rankedData to table "Table 1" of "Sheet 3"
-- Get the input string from cell A1 of the active sheet
set inputStr to "A1" of table "Table 1" of sheet "Sheet 1"
-- Unpack the string into 3 digits until exhausted
set digits to {}
repeat with i from 1 to the length of inputStr by 3
set end of digits to text i thru (i + 2) of inputStr
end repeat
-- Write the digits to the new sheet
tell table 1 of sheet 2
repeat with i from 1 to the length of digits
make new row at end with properties {values:{item i of digits}}
end repeat
end tell
end tell
My blue print
Sample of my google result
thanks as always, open to suggestions and what you have e.t.c
MacBook Air