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.
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.
- Choose the table and yearB19013 · median household income · 2024
- Choose the geographyEvery ZIP Code Tabulation Area
- Variables discoveredEstimate, margin of error and annotations, from the API's metadata
- Request the US Census Bureau APIBatched and retried; the key never leaves the analyst's environment
- Raw response savedUntouched, with metadata and quality notes
- 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_ID | NAME | B19013_001E | B19013_001EA | B19013_001M | zip code tabulation area |
|---|---|---|---|---|---|
| 860Z200US00601 | ZCTA5 00601 | 19454 | 1546 | 00601 | |
| 860Z200US00602 | ZCTA5 00602 | 21420 | 1811 | 00602 | |
| 860Z200US00603 | ZCTA5 00603 | 20933 | 1650 | 00603 | |
| 860Z200US00636 | ZCTA5 00636 | -666666666 | - | -222222222 | 00636 |
| 860Z200US00646 | ZCTA5 00646 | 36265 | 4517 | 00646 |
Finished dataset
| zipcode | Median-Household-Income |
|---|---|
| 00601 | 19454 |
| 00602 | 21420 |
| 00603 | 20933 |
| 00636 | (blank) |
| 00646 | 36265 |
33,772ZIP code areas in the dataset
3,225suppressed values left blank, not zero
0duplicate ZIP code areas
PASSoverall data-quality status
- Analyst runs one commandTable ID and year
- US Census Bureau APIMetadata and batched requests
- ExtractRaw data, metadata, quality notes
- TransformApproved names, ZIP padding, sum checks
- ReviewTeam checks the report
- 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
| Before | Now |
|---|---|
| Writing a new script for each table | One extractor, any table ID |
| Renaming columns by hand | Approved mapping applied automatically |
| Padding ZIP codes in a spreadsheet | Done in the transform stage |
| Eyeballing totals | Sum checks written to a report |
| Uploading and logging files manually | Load stage registers the file |
Built with
- Python
- US Census Bureau API
- Google Apps Script
The Agency services applied
What would you like your business to do better?
Tell us about the process, system or customer experience you want to improve.