Last active
August 29, 2015 14:03
-
-
Save pastcompute/b32f65f82c7889cdfa86 to your computer and use it in GitHub Desktop.
Script to make a SQL table definition from CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "create table raw_data ( `head -1 raw_data.csv | sed -e 's/\?//g' -e 's/ /_/g' -e 's/,/ text,/g' -e 's/$/ text'`);" > raw_data.table.sql | |
echo "copy raw_data from '`pwd`/raw_data.csv' csv header; | |
echo "grant all privileges on table raw_data to seeu"; | |
psql mydb < raw_data.table.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to be postgres user to use copy which is annoying