Forked from simonw/json-objects-into-a-datasette.md
Created
September 19, 2025 04:16
-
-
Save djd0723/08f32691ccac03e56e966d28695ce92f to your computer and use it in GitHub Desktop.
Revisions
-
simonw revised this gist
Sep 19, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ This repository has a dataset of 184.879 crimes committed in Buenos Aires: https Download the raw data like this: wget 'https://github.com/ramadis/delitos-caba/releases/download/3.0/delitos.json' Now use Pandas to load that into a dataframe: -
Simon Willison revised this gist
Jan 20, 2018 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,13 +31,19 @@ Pandas can save that file to a SQLite database like so: Now you can deploy that SQLite file as a web-based API using datasette publish. You'll need to install [Zeit Now](https://zeit.co/now) and [Datasette](https://github.com/simonw/datasette) first. Include source information with command-line options: datasette publish now delitos.db --source_url="https://github.com/ramadis/delitos-caba" --source="ramadis/delitos-caba" > Deploying /private/var/folders/jj/fngnv0810tn2lt_kd3911pdc0000gp/T/tmpcagpkk5f/datasette under simonw > Ready! https://datasette-tkgtsfyjyj.now.sh (copied to clipboard) [6s] > Synced 2 files (399B) [0ms] > ... A few seconds later: https://datasette-tkgtsfyjyj.now.sh Let's give it a nice URL: now alias https://datasette-tkgtsfyjyj.now.sh delitos-caba.now.sh Now you can visit it at https://delitos-caba.now.sh/ -
Simon Willison revised this gist
Jan 20, 2018 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -37,4 +37,8 @@ A few seconds later: https://datasette-dexnovmlol.now.sh Let's give it a nice URL: now alias https://datasette-dexnovmlol.now.sh delitos-caba.now.sh Now you can visit it at https://delitos-caba.now.sh/ Here's an example SQL query showing the most common barrios: https://delitos-caba.now.sh/delitos-6395324?sql=select+%22barrio%22%2C+count%28%2A%29+as+%22count%22+from+delitos++group+by+%22barrio%22+order+by+%22count%22+desc+limit+100 -
Simon Willison created this gist
Jan 20, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ # How to turn a list of JSON objects into a Datasette This repository has a dataset of 184.879 crimes committed in Buenos Aires: https://github.com/ramadis/delitos-caba Download the raw data like this: wget 'https://raw.githubusercontent.com/ramadis/delitos-caba/master/delitos.json' Now use Pandas to load that into a dataframe: >>> import pandas as pd >>> df = pd.read_json(open('delitos.json')) >>> df barrio cantidad_vehiculos cantidad_victimas comuna \ 0 FLORESTA 2 0 Comuna 10 1 PALERMO 1 0 Comuna 14 2 VILLA CRESPO 3 0 Comuna 15 3 PARQUE AVELLANEDA 1 0 Comuna 9 4 VILLA GRAL MITRE 1 0 Comuna 11 5 FLORESTA 2 0 Comuna 10 6 PARQUE CHACABUCO 1 0 Comuna 7 7 RECOLETA 4 0 Comuna 2 8 FLORES 2 0 Comuna 7 9 NUEVA POMPEYA 2 0 Comuna 4 Pandas can save that file to a SQLite database like so: >>> import sqlite3 >>> conn = sqlite3.connect('delitos.db') >>> df.to_sql('delitos', conn) Now you can deploy that SQLite file as a web-based API using datasette publish. You'll need to install [Zeit Now](https://zeit.co/now) and [Datasette](https://github.com/simonw/datasette) first. datasette publish now delitos.db A few seconds later: https://datasette-dexnovmlol.now.sh Let's give it a nice URL: now alias https://datasette-dexnovmlol.now.sh delitos-caba.now.sh