Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 79c8b6302c6b681ef8bc890c0d8d7cce01db63f2 1 parent ce61d9f
Joe Germuska JoeGermuska authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 tools/sql/ire_export/load_psql.sh
11 tools/sql/ire_export/load_psql.sh
View
@@ -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}
Please sign in to comment.
Something went wrong with that request. Please try again.