Skip to content

Instantly share code, notes, and snippets.

@TheOpenDevProject
Created February 6, 2017 04:11
Show Gist options
  • Save TheOpenDevProject/d85d3e941bec0139df2fdf4b3d965b9b to your computer and use it in GitHub Desktop.
Save TheOpenDevProject/d85d3e941bec0139df2fdf4b3d965b9b to your computer and use it in GitHub Desktop.
CSV => SQL
cat file.csv | awk -F$'\t' '{ printf "INSERT INTO country_details VALUES (\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27,\x27%s\x27);",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19;print ""}' > final.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment