All work

Agency project

Census Extraction Tool

Change a table ID, not the code.

Choose a Census table and year, and get back a checked dataset ready for analysis.

Year
2026
Current status
Live for a global agency

Problem, build and result

At a glance

The problem

Each time the analysts needed a US Census table, someone wrote or adapted a script for it, then renamed columns, padded ZIP codes and checked totals by hand before the data could be used. Every new table meant repeating that work.

My role

Designed and built in-house for the analysts who use it.

The Agency’s solution

One extraction tool. An analyst chooses a Census table and year; it requests every ZIP code area from the US Census Bureau API in batches with retries, applies the approved column names and checks, and returns the dataset with a data-quality report. The raw response is kept alongside, and the finished file is registered with the team's master sheet.

What it enables

Analysts get a consistent, checked dataset for any table with one command, so their time goes into analysis rather than preparation. Missing values stay missing instead of quietly becoming zero.

One run, from request to dataset

A real run on public data: ACS 5-year 2024, table B19013, median household income. No client or employer information.

  1. Choose the table and yearB19013 · median household income · 2024
  2. Choose the geographyEvery ZIP Code Tabulation Area
  3. Variables discoveredEstimate, margin of error and annotations, from the API's metadata
  4. Request the US Census Bureau APIBatched and retried; the key never leaves the analyst's environment
  5. Raw response savedUntouched, with metadata and quality notes
  6. Dataset producedApproved names, ZIPs kept as 5-digit text, suppressed values blank

The API request

GET https://api.census.gov/data/2024/acs/acs5
    ?get=GEO_ID,NAME,B19013_001E,B19013_001EA,B19013_001M,B19013_001MA
    &for=zip code tabulation area:*

Raw API response

GEO_IDNAMEB19013_001EB19013_001EAB19013_001Mzip code tabulation area
860Z200US00601ZCTA5 0060119454154600601
860Z200US00602ZCTA5 0060221420181100602
860Z200US00603ZCTA5 0060320933165000603
860Z200US00636ZCTA5 00636-666666666--22222222200636
860Z200US00646ZCTA5 0064636265451700646

Finished dataset

zipcodeMedian-Household-Income
0060119454
0060221420
0060320933
00636(blank)
0064636265

33,772ZIP code areas in the dataset

3,225suppressed values left blank, not zero

0duplicate ZIP code areas

PASSoverall data-quality status

DiagramExtract, transform, load
  1. Analyst runs one commandTable ID and year
  2. US Census Bureau APIMetadata and batched requests
  3. ExtractRaw data, metadata, quality notes
  4. TransformApproved names, ZIP padding, sum checks
  5. ReviewTeam checks the report
  6. LoadRegistered in the master sheet

Dashed: a person or outside system

What it does

  • Any table, same script

    Pass a table ID and year. Variables and their official labels are discovered from the API's own metadata.

  • Checks that know the table

    Generic checks run on every pull. Where a table has rules, like category totals that must add up, those run too.

  • Stages that don't overlap

    Extract never renames or drops anything. Transform never calls the API. Load only uploads a finished file.

  • Keys kept out of sight

    API keys and secrets live in each person's environment, and are scrubbed from errors and logs.

Manual steps it replaces

BeforeNow
Writing a new script for each tableOne extractor, any table ID
Renaming columns by handApproved mapping applied automatically
Padding ZIP codes in a spreadsheetDone in the transform stage
Eyeballing totalsSum checks written to a report
Uploading and logging files manuallyLoad stage registers the file

Built with

  • Python
  • US Census Bureau API
  • Google Apps Script

What would you like your business to do better?

Tell us about the process, system or customer experience you want to improve.