-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.sh
executable file
·43 lines (35 loc) · 1012 Bytes
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
RSCRIPT=Rscript
PYTHON=python
SQLITE_DB=cdb90.sqlite3
DAFF=daff.py
DATA_DIR=data
SRC_DIR=src-data
if [ -d "$DATA_DIR" ]
then
read -p "Delete contents of directory \"$DATA_DIR\" (y/n)?" yn
case "$yn" in
[Yy]* ) rm -rf $DATA_DIR/* ;;
[Nn]* ) echo "exiting"; exit 1 ;;
* ) echo "answer yes or no" ;;
esac
else
echo "Creating directory \"$DATA_DIR\""
mkdir -p "$DATA_DIR"
fi
# create files in ./data
$RSCRIPT create_data.R
# rebuild datapackage.json
echo "rebuilding datapackage.json"
$PYTHON make_datapackage.py
# Making daff diffs
echo "diffing original and patched CDB90 csvs"
$DAFF diff --output $SRC_DIR/CDB90/diff.csv --context 0 $SRC_DIR/CDB90/cdb90-orig.csv $SRC_DIR/CDB90/cdb90-patched.csv
$DAFF render --output $SRC_DIR/CDB90/diff.html $SRC_DIR/CDB90/diff.csv
# Load csv files into sqlite database
if [ -e "$SQLITE_DB" ]
then
rm $SQLITE_DB
fi
echo "loading data/*csv into SQLite database $SQLITE_DB"
$PYTHON load-sqlite.py datapackage.json $SQLITE_DB