Upgrade to Pro — share decks privately, control downloads, hide ads and more …

NACIS 2016 - Practical Cartography Day

NACIS 2016 - Practical Cartography Day

Bash and Make tips for scripting reproducible workflows

Avatar for Seth Fitzsimmons

Seth Fitzsimmons

October 19, 2016
Tweet

More Decks by Seth Fitzsimmons

Other Decks in Design

Transcript

  1. # why? # # * repeatable # * self-documenting #

    * transformations # <> data changes
  2. # on Windows 10? # no worries # # “Bash

    on Ubuntu # on Windows”
  3. # pipe # this means everything # can be combined!!!

    $ cat /etc/passwd | \ grep -i calendar
  4. if [[ “this” != “that” ]]; then echo Control Flow

    elif [[ ! -f file ]]; then touch file elif [[ $six -le $five ]]; then false else rm -f file fi
  5. $ make wilderness data/S_USA.Wilderness.zip: @mkdir -p $$(dirname $@) @curl -sfL

    http://data.fs.usda.gov/ geodata/edw/edw_resources/shp/ S_USA.Wilderness.zip \ -o $@
  6. $ make table db/wilderness: sql/wilderness.sql psql \ -c "\d $(subst

    db/,,$@)" \ > /dev/null \ 2>&1 || \ psql \ -v ON_ERROR_STOP=1 \ -qX1f \ $<
  7. # resources • https://bost.ocks.org/mike/make/ • http://www.gregreda.com/2013/07/15/unix- commands-for-data-science/ • https://google.github.io/styleguide/shell.xml •

    https://github.com/stamen/toner-carto/blob/ master/Makefile (WARNING!) • http://mojodna.net/2015/01/07/make-for-data- using-make.html