Skip to content

Instantly share code, notes, and snippets.

@simonw
Last active April 21, 2018 05:03
Show Gist options
  • Select an option

  • Save simonw/c0312e58f5321ca3ede0a71a5495f9d7 to your computer and use it in GitHub Desktop.

Select an option

Save simonw/c0312e58f5321ca3ede0a71a5495f9d7 to your computer and use it in GitHub Desktop.
How I created a Datasette instance for the Washington Post school shootings database

Here's the Datasette instance: https://washington-post-school-shootings.now.sh - using data from https://github.com/washingtonpost/data-school-shootings

$ wget https://raw.githubusercontent.com/washingtonpost/data-school-shootings/master/school-shootings-data.csv

I manually edited the first line of the CSV file, renaming the lat column to latitude and the long column to longitude. This is needed to get the datasette-cluster-map plugin to work correctly.

Then I created the SQLite database using csvs-to-sqlite, specifing specific fields that should be added to a full-text search index:

$ csvs-to-sqlite school-shootings-data.csv school-shootings-data.db \
  -f school_name -f district_name -f city -f state -f county

Then I published with Datasette and installed the cluster-map plugin:

$ datasette publish now school-shootings-data.db \
  --title="Washington Post: School Shootings" \
  --source="washingtonpost/data-school-shootings" \
  --source_url="https://github.com/washingtonpost/data-school-shootings" \
  --license="CC BY-NC-SA 4.0" \
  --license_url="https://creativecommons.org/licenses/by-nc-sa/4.0/" \
  --install="https://github.com/simonw/datasette-cluster-map/archive/master.zip" \
  --extra-options="--page_size=500" \
  --name=washington-post-school-shootings

Using the latest master version of datasette-cluster-map to get this change.

Finally, to give it a nicer URL:

$ now alias washington-post-school-shootings-irlqqgzpxv.now.sh \
  washington-post-school-shootings.now.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment