Numbers - with AppleScript how to populate data from one numbers table to another

 I would like to copy the values from one table in a Numbers sheet and put them into another table, but do not know how to implement the copying of the data from one table to another. Is a repeat statement needed? I have seen the examples at https://iworkautomation.com/numbers/table-populate.html and https://iworkautomation.com/numbers/tab … -file.html but they start at too an advanced level for me. 


Any help would be gratefully received.


The workflow is:


1. export some data from a database (Tap Forms) as a CSV file,

2. open the CSV file in numbers (Table 1).

3. delete the header row in Table 1,

4. create a new table in the active sheet (Table 2),

4. get a count of the rows,

5. go through all the rows of Table 1 and take the value of each cell and put them into Table 2


This is not the actual workflow but it is just a simplified example so I can understand how to do it. I can do 1 to 4 in the list, but I am stuck on 5. 


The CSV file is in the following format: 


Type of document,Country,Date notarised
Power of attorney 1,Spain,5 November 2021
Power of attorney 2 ,Spain,5 November 2021




As far as I have got with the AppleScript:



set Tap_Forms_file to (path to documents folder as text) & "Notarised documents.csv"

tell application "Numbers"
  activate
  open alias Tap_Forms_file
  tell document 1
    tell sheet 1
      tell table 1
        delete the first row
        set vcount to the count of rows
      end tell
    end tell
  end tell

  set the columnCount to 4
  set the rowCount to 6
  tell application "Numbers"
    activate
    if not (exists document 1) then error number -128
    tell document 1
      tell active sheet
        set thisTable to make new table with properties {column count:columnCount, row count:rowCount}
      end tell
    end tell
  end tell
end tell


iMac 27″ 5K, macOS 12.3

Posted on Apr 12, 2022 4:05 AM

Reply

Similar questions

3 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Numbers - with AppleScript how to populate data from one numbers table to another

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.