Public
Edited
Nov 25, 2023
Insert cell
Insert cell
toc()
Insert cell
Insert cell
reportdb = DuckDBClient.of({
report: FileAttachment("report.parquet")
})
Insert cell
reportdb
Select * from report limit 5
Insert cell
Insert cell
Insert cell
db = DuckDBClient.of({
progetti: getRemoteFile(
"https://raw.githubusercontent.com/aborruso/aborruso.github.io//main/posts/duckdb-intro-csv/file/PNRR_Progetti-Universo_REGIS_v2.1.parquet"
)
})
Insert cell
Insert cell
db
SELECT Missione, SUM("Finanziamento PNRR") AS total_PNRR
FROM progetti
GROUP BY ALL;
Insert cell
Inputs.table(summarize, { locale: "it-IT" })
Insert cell
Insert cell
Inputs.table(
db.sql`SELECT Missione, SUM("Finanziamento PNRR") AS total_PNRR FROM progetti GROUP BY ALL`,
{ locale: "it-IT" }
)
Insert cell
Insert cell
Insert cell
function getRemoteFile(url) {
const baseURL = new URL(url);
return {
file: {
name: baseURL.pathname,
url: function () {
return url;
}
}
};
}
Insert cell
Insert cell
function toc(selector = "h1,h2,h3", heading = "<b>Table of Contents</b>") {
return Generators.observe((notify) => {
let headings = [];

function observed() {
const h = Array.from(document.querySelectorAll(selector));
if (h.length !== headings.length || h.some((h, i) => headings[i] !== h)) {
notify(
html`${heading}<ul>${Array.from((headings = h), (h) => {
return Object.assign(
html`<li><a href=#${h.id}>${DOM.text(h.textContent)}`,
{ onclick: (e) => (e.preventDefault(), h.scrollIntoView()) }
);
})}`
);
}
}

const observer = new MutationObserver(observed);
observer.observe(document.body, { childList: true, subtree: true });
observed();
return () => observer.disconnect();
});
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more