Permalink
Browse files

super simple script to load IRE census data into a PSQL database. Edi…

…t the DATABASE variable to your needs.
  • Loading branch information...
1 parent ce61d9f commit 79c8b6302c6b681ef8bc890c0d8d7cce01db63f2 @JoeGermuska JoeGermuska committed Feb 23, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 tools/sql/ire_export/load_psql.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+TABLE=$1
+STATE=$2
+SUMLEV=$3
+LOWER_TABLE=`echo $TABLE | tr '[A-Z]' '[a-z]'`
+
+DATABASE='nicar'
+echo table $TABLE state $STATE sumlev $SUMLEV
+curl https://raw.github.com/ireapps/census/master/tools/sql/ire_export/ire_${TABLE}.sql | psql $DATABASE
+curl http://censusdata.ire.org/${STATE}/all_${SUMLEV}_in_${STATE}.${TABLE}.csv | gzcat > all_${SUMLEV}_in_${STATE}.${TABLE}.csv
+psql -c "copy ire_${LOWER_TABLE} from '/Users/germuska/src/all_${SUMLEV}_in_${STATE}.${TABLE}.csv' csv header" ${DATABASE}

0 comments on commit 79c8b63

Please sign in to comment.