Skip to content

feat: add download_cpa reader for Country Programmable Aid#40

Merged
jm-rivera merged 2 commits into
mainfrom
feat/cpa-reader
Jun 19, 2026
Merged

feat: add download_cpa reader for Country Programmable Aid#40
jm-rivera merged 2 commits into
mainfrom
feat/cpa-reader

Conversation

@jm-rivera

Copy link
Copy Markdown
Collaborator

What

Adds download_cpa() — an API reader for OECD Country Programmable Aid (DSD_CPA@DF_CRS_CPA).
It's a near-clone of the CRS reader: it reuses build_crs_filter, convert_crs_to_dotstat_codes,
and the CRS .stat schema (via a one-line cpacrs alias in read_schema_translation), defaults
to project-level microdata (MD_DIM=DD, confirmed against the live API), and is discoverable via
get_available_filters("cpa").

Closes #38.

Why API-only (no download_cpa_file)

The OECD per-year bulk .txt files for CPA are malformed upstream: 32–69% of rows in 2020–2023
carry more pipe-delimited fields than the 49-column header (structurally invalid — the API confirms
the source text has zero embedded delimiters; 2015 is clean, so it's a regression). They can't be
parsed losslessly, so per-year bulk is deferred to #39 and has been reported to the OECD. For a full
year, use download_cpa(start_year=y, end_year=y).

Changes

  • src/oda_reader/cpa.py (new) — download_cpa()
  • download_tools.py"cpa" dispatch entry (reuses CRS filter + converter)
  • schemas/schema_tools.pycpacrs schema alias
  • __init__.py — export download_cpa
  • tools.pyget_available_filters("cpa")
  • tests/datasets/cpa/ — 4 unit + 2 integration tests
  • README.md, CHANGELOG.md — CPA docs

Testing

  • uv run pytest -q193 passed, 8 deselected (integration excluded by default).
  • New offline unit tests: schema alias == CRS, filter parity == CRS, dataflow constants, and
    converter-wiring (version_functions["cpa"] uses convert_crs_to_dotstat_codes).
  • New live integration tests: raw + processed CPA query.
  • mdformat clean.

Co-authored-by: Claude noreply@anthropic.com

Adds download_cpa() sourcing OECD CPA (DSD_CPA@DF_CRS_CPA) from the SDMX
API, reusing the CRS filter, schema, and translation (via a cpa->crs
alias in read_schema_translation). Defaults to project-level microdata
(MD_DIM=DD). get_available_filters("cpa") is supported.

Per-year bulk (download_cpa_file) is intentionally omitted: the OECD bulk
.txt files are malformed upstream (32-69% of rows in 2020-2023 are
structurally invalid), tracked in #39 to add once OECD fixes them.

Co-authored-by: Claude <noreply@anthropic.com>
@jm-rivera jm-rivera marked this pull request as ready for review June 19, 2026 06:28
Add a Country Programmable Aid section to the docs site (datasets,
filtering, advanced) and update dataset counts/enumerations. Remove the
per-year bulk caveat from the README CPA section.

Co-authored-by: Claude <noreply@anthropic.com>
@jm-rivera jm-rivera requested a review from tillywoodfield June 19, 2026 06:37

@tillywoodfield tillywoodfield left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jm-rivera jm-rivera merged commit 02e34ba into main Jun 19, 2026
10 checks passed
@jm-rivera jm-rivera deleted the feat/cpa-reader branch June 19, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the CPA (Country Programmable Aid) dataset

2 participants