Created
March 18, 2022 19:12
-
-
Save joverlee521/f4dd05784019548a735ab26de4760002 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
# Modified for TSV based on the comment from @paulfitz at | |
# https://github.com/paulfitz/daff/issues/127#issuecomment-433538271 | |
if [[ -z "$2" ]]; then | |
echo "Call as foo.tsv foo.sqlite" | |
exit 1 | |
fi | |
header=$(head -n1 $1) | |
header=$(echo $header | sed "s/ /, /g") | |
header=$(echo $header | sed "s/,/ primary key,/") | |
echo $header | |
cat $1 | tail -n +2 | sqlite3 $2 "create table sheet($header);" ".mode tabs" ".import /dev/stdin sheet" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment