Inspiration
Kenya's 2024 FinAccess Household Survey (CBK, KNBS, FSD Kenya) ships as a 290 MB Excel workbook (~3 GB uncompressed XML) that is slow to open in desktop BI tools, and unweighted row counts produce wrong headline statistics.
What it does
prepare_finaccess.py streams xl/worksheets/sheet1.xml directly from the zip archive in 16 MB chunks, filters to 19,750 adult respondents weighted to 28.1M Kenyan adults, computes survey-weighted indicator columns (w_* = weight * flag), outputs an ~8 MB CSV + 47-county lookup table, and reconciles aggregates against published official figures before feeding a 5-page Power BI DAX report.
How I built it
- Streaming XML parser: Built a memory-bounded Python XML streamer with automatic topline reconciliation (fails if any weighted headline metric drifts by >= 0.05 percentage points).
- Weighted DAX model: Implemented weighted ratios (
SUM(Survey[w_*]) / SUM(Survey[weight])), county gap calculations, and small-sample caution flags (n < 250). - CI and verification: Tested ETL outputs and reconciliation gates with pytest and Ruff in GitHub Actions.
Verified Findings
- Topline match: 84.8% formal financial access, 5.2% informal only, and 9.9% excluded (reconciled to published FinAccess 2024 figures).
- County spread: Formal financial access varies from 48.5% to 94.0% across all 47 Kenyan counties.
- National ID gap: 63% of adults without a national ID are financially excluded, compared with 5% among ID holders.