Revision 11443
Added by Paul Sarando about 11 years ago
load-geoscrub-input.sh | ||
---|---|---|
18 | 18 |
|
19 | 19 |
# Note, to force data to download from DATA_URL, ensure the DATAFILE is deleted |
20 | 20 |
# before running this script. |
21 |
|
|
22 |
SCRIPT_DIR=$(dirname $0) |
|
21 | 23 |
DATA_URL="http://fs.vegpath.org/exports/geoscrub_input.no_header.cols=country,stateProvince,county,decimalLatitude,decimalLongitude.csv" |
22 |
DATADIR="$(dirname $0)/input"
|
|
24 |
DATADIR="${SCRIPT_DIR}/input"
|
|
23 | 25 |
DATAFILE="${DATADIR}/geoscrub-corpus.csv" |
24 | 26 |
|
25 | 27 |
if [[ ! -d "$DATADIR" ]]; then |
... | ... | |
42 | 44 |
fi |
43 | 45 |
fi |
44 | 46 |
|
45 |
# generate table |
|
46 |
psql -c \ |
|
47 |
'CREATE TABLE vegbien_geoscrub ( |
|
48 |
country text, |
|
49 |
stateProvince text, |
|
50 |
county text, |
|
51 |
decimalLatitude double precision, |
|
52 |
decimalLongitude double precision |
|
53 |
)' geoscrub |
|
47 |
echo "Loading vegbien data from ${DATAFILE}" |
|
54 | 48 |
|
49 |
# clear previous data |
|
50 |
psql -e -d geoscrub --set ON_ERROR_STOP=1 < "${SCRIPT_DIR}/truncate.vegbien_geoscrub.sql" |
|
51 |
if [[ $? != 0 ]]; then |
|
52 |
echo "Could not clear data from vegbien_geoscrub tables." |
|
53 |
exit 1 |
|
54 |
fi |
|
55 |
|
|
55 | 56 |
# load |
56 | 57 |
psql -c "COPY vegbien_geoscrub FROM '${DATAFILE}' WITH CSV" geoscrub |
57 | 58 |
|
Also available in: Unified diff
Initial checkin of geoscrub install SQL files.
Added install.*.sql files that will do initial table creation for all
required tables.
Added a truncate.vegbien_geoscrub.sql script that will clear tables related to
data downloaded in load-geoscrub-input.sh.
Moved all SQL statements that modify the final geoscrub table into the
geovalidate.sql script.
Modified the geonames.sql and geovalidate.sql scripts to assume all
tables have already been created by the install scripts.