Skip to content

feat: P2 enhancements — filtering, column selection, untyped data, performance - #2

Merged
thomaspinder merged 7 commits into
mainfrom
feat/p2-enhancements
Feb 21, 2026
Merged

thomaspinder merged 7 commits into
mainfrom
feat/p2-enhancements

Conversation

@thomaspinder

Copy link
Copy Markdown
Collaborator

Summary

Phase 2 enhancements to cbspy, adding power-user features to get_data() and improving performance for large tables.

New features

  • Generic dimension filtering (filters parameter) — Filter any dimension using a dict of key→value lists (e.g. filters={"RegioS": ["GM0363", "GM0599"]}) or a raw OData $filter string. Combines with the existing periods parameter via AND logic.
  • Column selection (columns parameter) — Restrict returned columns using human-readable names (e.g. "Total population") or CBS keys (e.g. "TotalPopulation_1"). Maps titles back to OData $select keys automatically, reducing bandwidth for wide tables.
  • UntypedDataSet support (typed=False) — Fetch from UntypedDataSet instead of TypedDataSet to preserve CBS statistical symbols (. = not applicable, x = suppressed, - = nil) that are normally replaced with null.
  • Half-yearly period decoding — Decode CBS codes like 2023HJ01 → "2023 H1" and 2023HJ02 → "2023 H2".

Performance

  • ODataFeed endpoint — Switched from /ODataApi/odata to /ODataFeed/OData, which has no 10,000-row page limit. This reduces HTTP round-trips for large tables from 50+ requests down to 1–5.

Documentation

  • Updated getting-started guide with examples for filters, columns, and typed parameters
  • Added half-yearly format to period codes reference
  • Fixed stale P1 references (removed dutch_name / display_name mentions)

Tests

  • 300+ lines of new tests covering:
    • Dict and raw-string filter modes
    • Combined periods + filters
    • Column selection with human-readable names and CBS keys
    • typed=True (default) vs typed=False dataset routing
    • Half-yearly period decoding
  • All existing tests updated for the new ODataFeed endpoint URL

Test plan

  • make check — linting (ruff) and type checking (ty) pass
  • make test — all tests pass with full coverage of new features
  • Manual smoke test against live CBS API with a large table (e.g. 71450ned)

🤖 Generated with Claude Code

thomaspinder and others added 7 commits February 21, 2026 16:48
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ODataFeed has no 10,000-row page limit, reducing HTTP round-trips
for large tables from 50+ requests to 1-5.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Accept a filters parameter as either a raw OData string or a dict
mapping dimension keys to value lists. periods param still works
and is combined with filters using AND.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Accept column names as human-readable titles or CBS keys.
Maps titles back to keys for the $select OData parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When typed=False, fetch UntypedDataSet to preserve CBS statistical
symbols (. = not applicable, x = suppressed, - = nil) instead of
replacing them with null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add documentation for filters, columns, typed parameters. Add
half-yearly period format. Remove references to deleted
dutch_name and display_name fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@thomaspinder
thomaspinder merged commit fbccd81 into main Feb 21, 2026
7 checks passed
@thomaspinder
thomaspinder deleted the feat/p2-enhancements branch February 21, 2026 16:12
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.

1 participant