Skip to content

Instantly share code, notes, and snippets.

@spara
Created February 6, 2012 17:12
Show Gist options
  • Select an option

  • Save spara/1753400 to your computer and use it in GitHub Desktop.

Select an option

Save spara/1753400 to your computer and use it in GitHub Desktop.
sed and gist to create sql
#
# create a sql script to create a table in postgres
# First step is extract the header
#
$ head -n 1 campus_dropout.csv > campus_header
#
# look at header
#
$ cat campus_header
#
# put each column name on a separate line and add sql type
# definition using sed
#
$ sed 's/,/ varchar,\
/g' campus_header > campus_dropout_raw.sql
#
# look at output
#
$cat campus_dropout_raw.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment