Skip to content

Instantly share code, notes, and snippets.

@ahebrank
Created May 21, 2018 14:03
Show Gist options
  • Select an option

  • Save ahebrank/752fdb77876ebe86276df100bca55e79 to your computer and use it in GitHub Desktop.

Select an option

Save ahebrank/752fdb77876ebe86276df100bca55e79 to your computer and use it in GitHub Desktop.
Bash helper to browse a CSV
#!/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