Under the hood of Canada Spends with Brendan Samek

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Shows a working recipe, Datasette plus LLM-driven PDF extraction with arithmetic cross-checks, for turning messy government PDFs into a queryable public database.

Read this as

Canada Spends is a website built by the volunteer group Build Canada that lets anyone browse Canadian government financial data, contracts, grants and transfers, in one place. Its founder Brendan Samek explains how the data is gathered, including using the AI model Gemini to pull numbers out of government PDF documents. The project's public database holds more than 2 million rows, including over 1.1 million contracts worth over $10,000.

Build Canada, a volunteer non-profit launched in February 2025, released Canada Spends to make Canadian government spending explorable by the public. Its stack combines Datasette, Ruby ingestion scripts, sqlite-utils and Gemini-powered PDF extraction, with sums cross-checked to catch extraction errors. A downloadable 2.4 GB SQLite database and live API instance are available, lowering the cost of civic-data scrutiny for journalists and researchers.

Brendan Samek walks through the Canada Spends architecture: Ruby ingestion scripts and sqlite-utils load scraped data into SQLite, served via a public Datasette instance at api.canadasbuilding.com with over 2 million rows and a combined search index over a denormalized copy. Audited financial statements are published as PDFs; Gemini extracts them, validated by cross-checking accounting sums. Tables include contracts-over-10k (1,172,575 rows), nserc_grants (701,310) and transfers (357,797).

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Canada Spends Build Canada Datasette sqlite-utils Gemini SQLite

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading

datasette-charts 0.5a0

Datasette Charts 0.5a0 adds calendar heatmaps, box plots and active-over-time charts, enabling richer data visualisation directly in the browser without extra libraries.