Links

Content Skeleton

This Page

Previous topic

numbers

Next topic

Numbers Applescript

NUMBERS

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 Numbers.app 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 Numbers.app

  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

Example:

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

Issues

  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.

NB

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

TODO

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

RANT

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

FUNCTIONS

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