feat: add download_cpa reader for Country Programmable Aid#40
Merged
Conversation
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>
8 tasks
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.statschema (via a one-linecpa→crsalias inread_schema_translation), defaultsto project-level microdata (
MD_DIM=DD, confirmed against the live API), and is discoverable viaget_available_filters("cpa").Closes #38.
Why API-only (no
download_cpa_file)The OECD per-year bulk
.txtfiles for CPA are malformed upstream: 32–69% of rows in 2020–2023carry 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.py—cpa→crsschema alias__init__.py— exportdownload_cpatools.py—get_available_filters("cpa")tests/datasets/cpa/— 4 unit + 2 integration testsREADME.md,CHANGELOG.md— CPA docsTesting
uv run pytest -q→ 193 passed, 8 deselected (integration excluded by default).converter-wiring (
version_functions["cpa"]usesconvert_crs_to_dotstat_codes).mdformatclean.Co-authored-by: Claude noreply@anthropic.com