tell application id "com.figure53.QLab.5" to tell front workspace
set listName to "fred"
set cueListExists to false
repeat with cl in cue lists
if q name of cl is listName then
set cueListExists to true
exit repeat
end if
end repeat
if cueListExists is false then
make type "cue list"
set newCue to last item of cue lists
set q name of newCue to listName
end if
end tell
-- Import a CSV file of EOS cues and make OSC triggers for them
-- this script assumes you have a Network Patch named EOS in QLab Settings->Network
set EOSinst to "From CIA select File - Export - CSV and select location (eg USB stick). Deselect All, then select Cues, click OK and enter file name and press Enter. Copy the csv files to Mac and then run this script. Configure Network and OSC on EOS/Desk and QLab/Mac"
display dialog EOSinst with title "To Export a Cues file from EOS"
-- set the seperator, for CSV generally comma
set sep to ","
-- Note: inside the tell Qlab the choose file only works with Posix form which is longer
set myfile to (choose file with prompt "Please select a CSV file containing EOS cues" of type {"csv"} default location (path to desktop))
-- while testing, specify the csv file directly
--set myfile to ((path to desktop) as string) & "eoscues.csv"
-- read the lines of file into an array
set myArray to every paragraph of (read file myfile)
--set myArray to every paragraph of (read POSIX file myFile)
set AppleScript's text item delimiters to sep
set cueinfo to {}
set ignoredCues to {}
set errors to {}
set nextFollows to false
tell application id "com.figure53.QLab.5" to tell front workspace
set myCuelistName to "EOS Imported"
try
set myCuelist to first cue list whose q name is myCuelistName
on error
display dialog "Cue list " & myCuelistName & " does not exist - do you want to create it" as string buttons {"Cancel", "Create Cue List"}
make type "cuelist"
set myCuelist to first cue list whose q name is "Cue List"
set q name of myCuelist to myCuelistName
end try
set current cue list to myCuelist
repeat with myline in myArray
-- split the line into an array on the comma separator
set myitems to every text item of myline
-- get the EOS specific columns
try
-- check if this is a Cue item
if (item 2 of myitems) is "Cue" then
set lxcuelist to item 3 of myitems
set lxcuenum to item 4 of myitems
set lxlabel to item 7 of myitems
set lxdur to item 18 of myitems
-- need to check these values so not to create triggers for part cues or follow on cues
set follow to item 24 of myitems
set part to item 6 of myitems
set lxnotes to item 32 of myitems
set lxscene to item 33 of myitems
if lxlabel is "" then
set lxlabel to "(no label) "
end if
if not nextFollows and part is "" then
make type "Network"
set newCue to last item of (selected as list)
set q number of newCue to "LX " & lxcuenum
set network patch name of newCue to "EOS"
set parameter values of newCue to "/eos/cue/" & lxcuelist & "/" & lxcuenum & "/fire"
-- flag snap cues
if lxdur is "0" then
set timelabel to " SNAP!"
set (q color of newCue) to "Orange"
else
set timelabel to " (" & lxdur & "s) "
end if
set q name of newCue to "LX" & lxcuenum & " - " & lxlabel & timelabel & " " & follow
set end of cueinfo to lxcuenum & " - " & lxlabel & timelabel & " " & follow & " " & part
else
set end of ignoredCues to lxcuenum & " - " & lxlabel & timelabel & " " & follow & " " & part
end if
-- check if follow has a value, so we don't create trigers for auto follow cues
if follow is "" then
set nextFollows to false
else
set nextFollows to true
end if
end if
on error errorMessage
set end of errors to errorMessage
end try
end repeat
set nl to linefeed
set AppleScript's text item delimiters to linefeed
display dialog (cueinfo as text) & nl & nl & (length of errors) & nl & "Ignored (autofollow, parts)" & nl & (ignoredCues as text) & nl & " errors" & nl & (errors as text) with title "Made " & (length of cueinfo) & " EOS trigger cues"
end tell
00000390: 2c00 2c00 0a00 3100 2c00 4300 7500 6500 ,.,...1.,.C.u.e.
000003a0: 2c00 3100 2c00 3100 2c00 4400 3100 3500 ,.1.,.1.,.D.1.5.
000003b0: 3300 4500 3100 4500 3900 2d00 3400 4600 3.E.1.E.9.-.4.F.
000003c0: 4300 3300 2d00 3400 4600 3700 3400 2d00 C.3.-.4.F.7.4.-.
000003d0: 3900 3900 4600 4400 2d00 4200 3900 3700 9.9.F.D.-.B.9.7.
000003e0: 4300 4100 4500 3800 3600 3200 3500 4100 C.A.E.8.6.2.5.A.
000003f0: 3100 2c00 2c00 4500 6900 6e00 6c00 6100 1.,.,.E.i.n.l.a.
00000400: 7300 7300 2c00 3500 2c00 2c00 2c00 2c00 s.s.,.5.,.,.,.,.
00000410: 2c00 2c00 2c00 2c00 2c00 2c00 3500 2c00 ,.,.,.,.,.,.5.,.
00000420: 2c00 2c00 2c00 2c00 2c00 2c00 2c00 2c00 ,.,.,.,.,.,.,.,.
00000430: 2c00 2c00 2c00 2c00 2c00 2c00 2c00 2c00 ,.,.,.,.,.,.,.,.
00000440: 2c00 2c00 0a00 3100 2c00 4300 7500 6500 ,.,...1.,.C.u.e
000001c0: 2c2c 2c2c 2c0a 312c 4375 652c 312c 312c ,,,,,.1,Cue,1,1,
000001d0: 4130 3137 4430 3630 2d31 3330 462d 3445 A017D060-130F-4E
000001e0: 3031 2d38 4130 412d 3746 3944 3135 3034 01-8A0A-7F9D1504
000001f0: 3643 4633 2c2c 4f6e 652c 352c 2c2c 2c2c 6CF3,,One,5,,,,,
00000200: 2c2c 2c2c 2c35 2c2c 2c2c 2c2c 2c2c 2c2c ,,,,,5,,,,,,,,,,
00000210: 2c2c 2c2c 2c2c 2c2c 2c0a 312c 4375 652c ,,,,,,,,,.1,Cue,
cat test_cues.csv | xxd -p | sed 's/00//g' | xxd -r -p > test_nonulls.csv
Brief explanation of this sequence of commands:
cat - show the contents of the file; pipe | into xxd - with the -p option dumps the file as bytes; sed - stream editor, substitutes the 00 for the nothing; xxd -r -p reads the bytes back in; then > sends the output to a new file.
attached is the converted file.
That will be a quick fix to make the script work, and when I get time I will look to see if I can deal that data file directly in the script. Be interesting to know what version of EOS it came from and if anything else was used to process in between (spreadsheet or whatever).
-- Import a CSV file of EOS cues and make OSC triggers for them
--- this version handles export csv file containing nulls
-- as a work around can remove nulls from the original file using the rather convoluted
-- cat test_cues.csv | xxd -p | sed 's/00//g' | xxd -r -p > test_nonulls.csv
-- [ unfortunately sed 's/\x0//g' doesn't work, at least on MacOS ]
-- this script assumes you have a Network Patch named EOS in QLab Settings->Network
set EOSinst to "From CIA select File - Export - CSV and select location (eg USB stick). Deselect All, then select Cues, click OK and enter file name and press Enter. Copy the csv files to Mac and then run this script. Configure Network and OSC on EOS/Desk and QLab/Mac"
--display dialog EOSinst with title "To Export a Cues file from EOS"
-- set the seperator, for CSV generally comma
set sep to ","
set myfile to (choose file with prompt "Please select a CSV file containing EOS cues" of type {"csv"} default location (path to desktop))
-- read the lines of file into an array
set myArray to every paragraph of (read file myfile)
set AppleScript's text item delimiters to sep
set cueinfo to {}
set ignoredCues to {}
set errors to {}
set nextFollows to false
set nl to linefeed
tell application id "com.figure53.QLab.5" to tell front workspace
set myCuelistName to "EOS Imported"
try
set myCuelist to first cue list whose q name is myCuelistName
on error
display dialog "Cue list " & myCuelistName & " does not exist - do you want to create it" as string buttons {"Cancel", "Create Cue List"}
make type "cuelist"
set myCuelist to first cue list whose q name is "Cue List"
set q name of myCuelist to myCuelistName
end try
set current cue list to myCuelist
set nextFollow to false
set results to {}
repeat with myline1 in myArray
------- kludge to remove nulls from string split the line on nulls to remove them
set AppleScript's text item delimiters to AppleScript's character id (0)
set tempArr to (every text item of myline1)
-- then rejoin the string without them
set AppleScript's text item delimiters to ""
set myline to tempArr as text
---------------- end of kludge ------------
-- split the line into an array on the comma separator
set AppleScript's text item delimiters to sep
set myitems to every text item of myline
set AppleScript's text item delimiters to linefeed
try
set rowtype to text item 2 of myitems
--display dialog (myitems as text) with title "my items, row type " & rowtype
if item 2 of myitems is "Cue" then
set part to item 6 of myitems
if not nextFollow and part is "" then
set lxcuelist to text item 3 of myitems
set lxdur to item 18 of myitems
set lxcuenum to item 4 of myitems
set lxlabel to item 7 of myitems
set follow to item 24 of myitems
set end of results to (lxcuenum & space & lxlabel) as string
set pv to ("/cue/" & lxcuelist & "/" & lxcuenum & "/fire") as string
make type "Network"
set netCue to last item of (selected as list)
set network patch name of netCue to "EOS"
set parameter values of netCue to pv
set q number of netCue to "LX" & lxcuenum
-- highlight snap cues
if lxdur is "0" then
set timelabel to " SNAP!"
set (q color of netCue) to "Orange"
else
set timelabel to " (" & lxdur & "s) "
end if
set q name of netCue to ("LX" & lxcuenum & " - " & lxlabel & timelabel & " " & follow) as string
else
set end of ignoredCues to (lxcuenum & space & label) as string
end if
-- don't make triggers for follow on cues
-- [this has not been tested with new data]
if follow is "" then
set nextFollow to false
else
set nextFollow to true
end if
end if
on error errMesg
set end of errors to errMesg
end try
end repeat
set nl to linefeed
set AppleScript's text item delimiters to linefeed
display dialog (results as text)
--display dialog (cueinfo as text) & nl & nl & (length of errors) & nl & "Ignored (autofollow, parts)" & nl & (ignoredCues as text) & nl & " errors" & nl & (errors as text) with title "Made " & (length of cueinfo) & " EOS trigger cues"
end tell
set myArray to paragraphs of (read file myfile as Unicode text)