I am trying to loop through each comma separated value in a file and have each item undergo a series of actions. Essentially the workflow is this:
CSV file:
123,456,789
Workflow:
[1] Take '123'
[2] Inject '123' into a text field
[3] Click on buttons
[4] Repeat until (and including) last value in CSV
My current code is as follows, but I'm not being able to correctly loop or inject the current item into the text field.
Any pointers you could give me?
set pathInputFile to (choose file with prompt "Select the CSV file" of type "csv")
set strFileContents to read pathInputFile
set parFileContents to (paragraphs of strFileContents)
set numRows to count of parFileContents
repeat with iPar from 1 to number of items in parFileContents
set lstRow to item iPar of parFileContents
if lstRow = "" then exit repeat -- EXIT Loop if Row is empty, like the last line
set lstFieldsinRow to parseCSV(lstRow as text)
----------
-- now I would need to pass the current value to the next block
-- and "paste" it into the text field
----------
tell application "System Events"
tell process "App"
set frontmost to true
click menu item "Query Window..." of menu "Network" of menu bar 1
click radio button "Number" of tab group 1 of window "Query"
set focused of text field 1 of tab group 1 of window "Query" to true
delay 0.1
keystroke "a" using command down
delay 0.1
keystroke "v" using command down
click UI element "Query" of group 4 of splitter group 1 of window "Query"
end tell
end tell
end repeat -- with iPar
EDIT:
set pathInputFile to (choose file with prompt "Select the CSV file" of type "csv")
set strFileContents to read pathInputFile
log strFileContents
Output:
(*147782
167482
182676
185309
184119
188494*)
What delimiter should I use in this case?