Content Skeleton

This Page

Previous topic


Next topic

Numbers Applescript


Although applescripts are extremely slow compared to using python approaches with xlwt/xlrd/xlutils the Applescript advantage is that formatting of the spreadsheet is retained (to the extent that is able to retain it).

Essentially the applescript duplicates the actions that could be done manually so the structure of the resultant updated spreadsheet should match those created by laborious manual cell-by-cell data entry. This is not the case with python tools : xlutils.copy.copy creates a fresh copy and loosing formatting information and potentially other things.

Usage Steps

  1. Open spreadsheet with

  2. Check that the frontmost spreadsheet contains a worksheet named numbers-sheetname

  3. To export a CSV file into PWD:

    numbers-export out.csv
  4. To import into the current spreadsheet:

    numbers-import in.csv


delta:Desktop blyth$ open Example_eng.xls
delta:Desktop blyth$ numbers-
delta:Desktop blyth$ numbers-import export.csv
=== numbers-import : path /Users/blyth/Desktop/export.csv
sheetname Journal paper toprow 3


  1. “volume and page number” fields giving “0” when look like mathematical expression eg “99/10000”. This only happens when importing into the empty template spreadsheet, not when adding rows to a spreadsheet existing entries.


The import/export CSV use character “|” as delimiter so fields cannot include that character. There is currently no checking of that.


  1. check for presense of the delimiter character in fields and refuse to export


Why require input in proprietry undocumented binary file formats ? Why not something simple like CSV ?


numbers-import path
import CSV path into the frontmost spreadsheet
numbers-export path
export CSV path from the frontmost spreadsheet, exporting is much much faster than importing
dump the sheetname and toprow that is imported/exported