Command line usage

Running bake --help will give you details of the command line arguments.

Generally you'll run bake recipe.py spreadsheet.xls.

By default, a CSV file is generated in the same folder as the spreadsheet called data-recipe-spreadsheet.csv. You can turn this off by putting --nocsv before the recipe.

You can also get a coloured version of the spreadsheet in the same folder called preview-recipe-spreadsheet.xls by using --preview.

The colours in a --preview spreadsheet represent:

  • OBS, lavender
  • DATAMARKERS, violet,
  • TIMEs, light blue,
  • TIMEUNITS, blue,
  • GEOG, sea green.

You can also suppress some of the output by adding --notiming.

There's also a --debug option which will put you in a Python session with the tables loaded.

You can also pass parameters by putting them after the spreadsheet file name. You can access these in the recipe with PARAMS().

Running from a Windows batch file

bake can be used in a batch file.

For example, if we place the recipes earn01.py and earn03.py along with the relevant spreadsheets table-earn01.xls and table-earn03.xls and add this batch file process.bat all together in the same directory:

bake earn01.py table-earn01.xls
bake earn03.py table-earn03.xls

Running process.bat will then process both of the spreadsheets with databaker in which they appear in the batch file.

It's also possible to run the same recipe on multiple files this way:

bake earn01.py table-earn01-2013.xls
bake earn01.py table-earn01-2014.xls

Recipes

Recipe overview

Recipes are short Python scripts (text files) containing two functions:

  • per_file which selects the tabs from a spreadsheet that will be processed;
  • per_tab which defines the cells that contain the observations to be saved, along with the corresponding dimensions that will be recorded for each observation.

Downloading example recipes

Some example spreadsheets and recipes are available from eot-recipes.

Or download them directly from master.zip.

Making and editing recipes

You can use any text editor to edit recipes.

Notepad++ is a good one for Windows with syntax highlighting.

We recommend turning tabs into spaces:

Settings -> Preferences... -> Language Menu/Tab Settings -> Tab Settings (group) -> Replace by space

4-space tabs are standard in Python.

How many recipes to make

If a spreadsheet has multiple tabs, it may be possible to use the same recipe for those tabs if they have identical (or very similar layouts).

In other cases, a spreadsheet may have tabs with very different layouts. In this case, it's necessary to use per_file in the recipe to specify the tabs that the recipe works with.

It's possible then that you may need to make multiple different recipes to handle all the tabs of interest for a given spreadsheet. In the worst case, you would then need one recipe for each tab you wish to extract.