Medallion Architecture · Layer 01

🥉

Bronze Layer

I ingested raw CSV files from 5 federal agencies directly into Delta Lake tables with minimal transformation. Every row is stamped with ingested_at and source_file for full lineage traceability.

8Notebooks
33Delta Tables
52.8MRows Ingested
5Federal Agencies
Bronze Silver Gold Analytics Machine Learning

What the Bronze Layer Does

The Bronze layer is the raw ingestion layer of the Medallion Architecture. I read each source CSV file exactly as received from the federal agency and write it to a Delta Lake table with zero business logic applied — only structural fixes like column name sanitization to comply with Delta's naming rules.

Every Bronze table includes two metadata columns: ingested_at (timestamp of when the row was ingested) and source_file (the exact filename it came from). This ensures full data lineage — I can always trace any row in the warehouse back to its exact source file.

The Bronze layer handles the project's most complex ingestion challenges: a wildcard read of 23 annual AQI files into one unified table, a 15.3 million row water violations file, a tab-delimited USDA livestock file misidentified as CSV, and 26 NPDES/SDWIS files ingested via a loop pattern into separate tables.

Bronze Ingestion Notebooks

01
Cancer Mortality Ingestion
01_ingest_cancer_mortality.py

Ingests CDC WONDER cancer mortality data (2018–2023) into the Bronze layer. Discovers and fixes the Delta column naming issue (spaces not allowed) — a fix carried forward into all subsequent notebooks.

CDC WONDER 394 rows Column sanitization
02
Cancer Incidence Ingestion
02_ingest_cancer_incidence.py

Ingests CDC WONDER cancer incidence data (1999–2022) — the primary outcome variable for the entire project. Uses a generic sanitizer function that lowercases and snake_cases all column names.

CDC WONDER 1,307 rows 24 years
03
EPA Air Quality Ingestion
03_ingest_air_quality.py

Reads all 23 annual AQI county-level files (2000–2022) in a single wildcard Spark read, unions them automatically, and uses Unity Catalog's _metadata.file_path to tag each row with its source file.

EPA AQS 24,488 rows 23 files · wildcard read
04
CDC Chronic Disease Ingestion
04_ingest_chronic_disease.py

Ingests the CDC Chronic Disease Indicators dataset — a long-format file with 34 columns covering 19 chronic disease topics including Cancer, Tobacco, Diabetes, COPD, and Cardiovascular Disease.

CDC BRFSS 398,793 rows 19 topics
05
SDWIS Water Quality Ingestion
05_ingest_sdwis_water_quality.py

Ingests all 11 EPA SDWIS files using a loop pattern — including the 15.3 million row violations file (the largest in the project). Uses try/catch per file with a summary report at the end.

EPA SDWIS 22.4M rows 11 tables · loop pattern
06
NPDES / CAFO Ingestion
06_ingest_npdes_cafo.py

Ingests all 15 EPA ECHO NPDES files covering CAFO permits, inspections, violations, and enforcement actions. Uses the same loop pattern as SDWIS — 15/15 success in one run.

EPA ECHO 23M rows 15 tables · loop pattern
07
Food Environment Atlas Ingestion
07_ingest_food_environment.py

Ingests the USDA Food Environment Atlas — already in long format (one row per county × variable_code), contrary to the wide format expected from the handoff doc. Also ingests the variable list dictionary.

USDA ERS 957,753 rows 304 variables
08
USDA Livestock Ingestion
08_ingest_usda_livestock.py

Ingests the 2.24 GB USDA Census of Agriculture QuickStats file — a tab-delimited .txt file misidentified as CSV. Uses delimiter detection to discover the tab separator before reading the full 6M row file.

USDA NASS 6,077,214 rows Tab-delimited · 2.24 GB