Created
May 21, 2018 14:03
-
-
Save ahebrank/752fdb77876ebe86276df100bca55e79 to your computer and use it in GitHub Desktop.
Bash helper to browse a 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
| #!/bin/bash | |
| # requirements: | |
| # - pip3 install datasette csvs-to-sqlite | |
| # - replace "open" below with "sensible-browser", etc., for other OS | |
| if [ $# -lt 1 ]; then | |
| echo "Need one or more csv" | |
| exit 1 | |
| fi | |
| fn=$( mktemp /tmp/csv.db.XXXXX ) | |
| trap ctrl_c INT | |
| function ctrl_c() { | |
| echo "Cleaning up..." | |
| rm $fn | |
| exit 0 | |
| } | |
| csvs-to-sqlite "$@" $fn | |
| sleep 2 && open http://localhost:8001 & | |
| datasette serve $fn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment