Join JSON responses into CSV-style rows with dotted-path projection — a Tabular Helper API.
Project description
tha-map-runner
A small Python library that joins a list of row dicts with a lookup source on a key, projecting values into flat row columns via a mapping config.
Think "left join between rows and a lookup source, with dotted-path projection on the source side."
Install
pip install tha-map-runner
Quick start
from tha_map_runner import enrich_rows
rows = [
{"Org BK": "school-001", "Start Date": "08/15"},
{"Org BK": "school-002", "Start Date": "08/16"},
]
api_response = [
{"sourcedId": "school-001", "name": "Lincoln Elementary", "parent": {"sourcedId": "dist-A"}},
{"sourcedId": "school-002", "name": "Roosevelt Middle", "parent": {"sourcedId": "dist-A"}},
]
enriched = enrich_rows(
rows=rows,
source=api_response,
mapping={
"Org Name": "name",
"Parent BK": "parent.sourcedId",
},
row_key="Org BK",
source_key="sourcedId",
)
How it works
- Builds an index of
sourceonsource_key— O(n+m), no nested loops - For each row, looks up a match by
row[row_key] - Walks dotted paths (
"parent.sourcedId") into the matched source entry - Projects resolved values into new columns on a copy of the row
- Returns a new list — input is never mutated
Rows whose row status is in skip_statuses are passed through unchanged.
API
enrich_rows(
rows, # list of row dicts
source, # list of dicts to join against
mapping, # {"output_column": "dotted.path"} — callable values planned
row_key, # column name in rows to match on
source_key, # field in source to match on
*,
on_no_match="skip", # "skip" | "error" | "blank"
allow_empty_source=False, # if True, empty source is not an error
skip_statuses=["error", "warning"],# rows with these statuses are passed through
) -> list[dict]
on_no_match
| Value | Behaviour |
|---|---|
"skip" |
Row is returned unchanged — no new columns added |
"error" |
row status="error", message=..., mapping columns set to "" |
"blank" |
Mapping columns set to "", row status untouched |
skip_statuses
By default, rows already marked row status="error" or row status="warning" are passed through without processing. Override with any list:
enrich_rows(..., skip_statuses=["error"]) # only skip errors
enrich_rows(..., skip_statuses=["error", "pending"]) # custom statuses
enrich_rows(..., skip_statuses=[]) # process every row regardless
Composing with tha-csv-runner
from tha_csv_runner import ThaCSV
from tha_map_runner import enrich_rows
import requests
runner = ThaCSV()
runner.read("Step 1 of 2", "input.csv", ["Org BK"])
api_response = requests.get(api_url).json()
runner.rows = enrich_rows(
rows=runner.rows,
source=api_response,
mapping={"Org Name": "name", "District": "parent.sourcedId"},
row_key="Org BK",
source_key="sourcedId",
)
runner.write("Step 2 of 2", "output.csv")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tha_map_runner-0.1.0.tar.gz.
File metadata
- Download URL: tha_map_runner-0.1.0.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ca262560ddd0a30f07ab48f43c71714d1b425cf8c86109248bcdbbe58efc164
|
|
| MD5 |
eaa670ba0bf81fd798d0bb2d09bd57b6
|
|
| BLAKE2b-256 |
e0ca5f6ff72cdc73b967b07f18b1a293ffa258c96e5d8e9098b0756b9591298d
|
Provenance
The following attestation bundles were made for tha_map_runner-0.1.0.tar.gz:
Publisher:
publish.yml on tha-guy-nate/tha-map-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tha_map_runner-0.1.0.tar.gz -
Subject digest:
4ca262560ddd0a30f07ab48f43c71714d1b425cf8c86109248bcdbbe58efc164 - Sigstore transparency entry: 1515909013
- Sigstore integration time:
-
Permalink:
tha-guy-nate/tha-map-runner@5da1daa76ece50c069ddf3b0f04101e3f8856433 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tha-guy-nate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5da1daa76ece50c069ddf3b0f04101e3f8856433 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tha_map_runner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tha_map_runner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2193de5d2b06439cf39e120a2fdc715b90e170098a3acbb5afc822005072c59c
|
|
| MD5 |
d330948fa3d0aaddc59ced12d6c50824
|
|
| BLAKE2b-256 |
767f19f75f0bef690f096cbd81ab66b920321b02ce641c9862c29237acffcc28
|
Provenance
The following attestation bundles were made for tha_map_runner-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on tha-guy-nate/tha-map-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tha_map_runner-0.1.0-py3-none-any.whl -
Subject digest:
2193de5d2b06439cf39e120a2fdc715b90e170098a3acbb5afc822005072c59c - Sigstore transparency entry: 1515909128
- Sigstore integration time:
-
Permalink:
tha-guy-nate/tha-map-runner@5da1daa76ece50c069ddf3b0f04101e3f8856433 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tha-guy-nate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5da1daa76ece50c069ddf3b0f04101e3f8856433 -
Trigger Event:
push
-
Statement type: