Skip to content

Instantly share code, notes, and snippets.

@Bilbottom
Last active May 9, 2024 06:18
Show Gist options
  • Save Bilbottom/5c1399fc160f7b427556a36c7b9888d3 to your computer and use it in GitHub Desktop.
Save Bilbottom/5c1399fc160f7b427556a36c7b9888d3 to your computer and use it in GitHub Desktop.
DuckDB for dynamically parsing JSON data from a URL
/*
DuckDB for dynamically parsing JSON data from a URL
DuckDB version: 0.10.2
Bill Wallis, 2024-05-09
*/
select version();
select
division,
unnest(events.events, recursive:=true),
from (
unpivot 'https://www.gov.uk/bank-holidays.json'
on "england-and-wales", "scotland", "northern-ireland"
into
name division
value events
);
division title date notes bunting
england-and-wales New Year’s Day 2018-01-01 true
england-and-wales Good Friday 2018-03-30 false
england-and-wales Easter Monday 2018-04-02 true
england-and-wales Early May bank holiday 2018-05-07 true
england-and-wales Spring bank holiday 2018-05-28 true
england-and-wales Summer bank holiday 2018-08-27 true
england-and-wales Christmas Day 2018-12-25 true
england-and-wales Boxing Day 2018-12-26 true
@Bilbottom
Copy link
Author

Bilbottom commented May 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment