Paste content into Numbers then export as CSV
I am trying to make an Apple script that does the following:
- Create a new Numbers sheet
- Paste the clipboard contents into cell A1. The clipboard content is a list, so each line of the list should be in a different cell. The number of lines in the list is variable.
- Every cell in the B column should have "missing". So if the clipboard list has 10 lines, the A column will have 10 rows and B1 - B10 will have "missing" in each cell.
- Export the Numbers sheet on the desktop in CSV format with the name as "missing.csv".
- Close the Numbers sheet without saving.
This is what I have so far:
tell application "Numbers"
activate
set thisDocument to make new document
end tell
tell application "Numbers" to tell document 1 to tell sheet 1 to tell table 1
set value of cell "a1" to (the clipboard as text)
set value of cell "b1" to "missing"
end tell
This is what I am stuck on:
a) Pasting the clipboard as a list, so each line of the clipboard appears in a seperate cell: At the moment, the whole list ends up in A1
b) Getting the B column to have the words "missing" so it matches up with the number of cells in column A.
c) Export as CSV and then closing the file.
Can someone give me some pointers? Thanks!
MacBook