-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake.sh
executable file
·72 lines (56 loc) · 1.31 KB
/
make.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
# Tracks, builds, and converts Handbook of the Mammals of the World (HMW) portion of
# Plazi's Treatment Bank into HMW specific json, and csv files.
#
#
set -x
function track {
# downloads latest copy of Plazi's treatments-xml and versions them
preston track https://github.com/plazi/treatments-xml/archive/master.zip
}
function build {
# convert a versioned copy of Plazi's Treatments-XML into JSON (Javascript Object Notation)
preston plazi-stream\
| grep "Handbook of the Mammals of the World"\
> hmw.json
}
function convert {
# converts Preston generated json into tabular csv
time cat hmw.json\
| jq -f schema.jq\
| mlr --ijson --ocsv cat\
| tee hmw.csv
}
function create_samples {
cat hmw.csv\
| head -n11\
> hmw-sample.csv
cat hmw.json\
| head -n10\
| tee hmw-sample.json\
| jq .\
> hmw-sample-pretty.json
seq 1 9\
| xargs -L1 -I {} sh -c 'cat hmw.csv | head -n1 > hmw-volume-{}.csv'
seq 1 9\
| xargs -L1 -I {} sh -c 'cat hmw.csv | grep "Volume {}" >> hmw-volume-{}.csv'
cat hmw.json\
| jq --raw-output .name\
| sort\
| uniq\
> names.txt
}
function check {
cat hmw.json\
| ./check.sh\
| wc -l
}
preston version
time track\
| tee hmw-prov.nq\
| build
convert
create_samples
echo number of records found with unexpected empty field values:
check