Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 24 lines (21 sloc) 1.042 kB
79c8b63 @JoeGermuska super simple script to load IRE census data into a PSQL database. Edi…
JoeGermuska authored
1 #!/usr/bin/env bash
18de79e @JoeGermuska add a little documentation
JoeGermuska authored
2 # usage: ./load_psql.sh [TABLE CODE] [STATE FIPS CODE] [SUMMARY LEVEL]
3 # supports all 331 Census 2010 tables
4 # only the five summary levels supported by the IRE Census app:
5 # 040 State
6 # 050 County
7 # 060 County Subdivision
8 # 140 Census Tract
9 # 160 Place
10 # see also http://census.ire.org/data/bulkdata.html
11 # list of FIPS state codes at http://en.wikipedia.org/wiki/Federal_Information_Processing_Standard_state_code#FIPS_state_codes
12
13 # change this to your default database, or tweak the script to make it a parameter
14 DATABASE='nicar'
15
79c8b63 @JoeGermuska super simple script to load IRE census data into a PSQL database. Edi…
JoeGermuska authored
16 TABLE=$1
17 STATE=$2
18 SUMLEV=$3
19 LOWER_TABLE=`echo $TABLE | tr '[A-Z]' '[a-z]'`
20
21 echo table $TABLE state $STATE sumlev $SUMLEV
22 curl https://raw.github.com/ireapps/census/master/tools/sql/ire_export/ire_${TABLE}.sql | psql $DATABASE
23 curl http://censusdata.ire.org/${STATE}/all_${SUMLEV}_in_${STATE}.${TABLE}.csv | gzcat > all_${SUMLEV}_in_${STATE}.${TABLE}.csv
24 psql -c "copy ire_${LOWER_TABLE} from '/Users/germuska/src/all_${SUMLEV}_in_${STATE}.${TABLE}.csv' csv header" ${DATABASE}
Something went wrong with that request. Please try again.