Created
February 6, 2012 17:12
-
-
Save spara/1753400 to your computer and use it in GitHub Desktop.
sed and gist to create sql
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
| # | |
| # 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