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 ThaMap
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"}},
]
mapper = ThaMap()
enriched = mapper.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
ThaMap
ThaMap()
mapper.enrich_rows()
mapper.enrich_rows(
rows, # list of row dicts
source, # list of dicts to join against
mapping, # {"output_column": "dotted.path"}
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]
Results are also stored in mapper.rows.
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:
mapper.enrich_rows(..., skip_statuses=["error"]) # only skip errors
mapper.enrich_rows(..., skip_statuses=["error", "pending"]) # custom statuses
mapper.enrich_rows(..., skip_statuses=[]) # process every row regardless
Composing with tha-csv-runner
from tha_csv_runner import ThaCSV
from tha_map_runner import ThaMap
import requests
runner = ThaCSV()
runner.read("Step 1 of 2", "input.csv", ["Org BK"])
api_response = requests.get(api_url).json()
mapper = ThaMap()
enriched = mapper.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", rows=enriched)
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.2.tar.gz.
File metadata
- Download URL: tha_map_runner-0.1.2.tar.gz
- Upload date:
- Size: 33.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
259da5376de92017dcc1b6a8caa5e3dba9e124353271d55e0de55552e3c82724
|
|
| MD5 |
3feb8c8b2116c205a4865252a31b79ac
|
|
| BLAKE2b-256 |
a782254d41e98803992852ca3f4b581329d0410675ebe41b804a46febdfcaeb6
|
Provenance
The following attestation bundles were made for tha_map_runner-0.1.2.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.2.tar.gz -
Subject digest:
259da5376de92017dcc1b6a8caa5e3dba9e124353271d55e0de55552e3c82724 - Sigstore transparency entry: 1551900950
- Sigstore integration time:
-
Permalink:
tha-guy-nate/tha-map-runner@0bd11e22d18b4e761348fc797a7336aa03ab3f27 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/tha-guy-nate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0bd11e22d18b4e761348fc797a7336aa03ab3f27 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tha_map_runner-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tha_map_runner-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.4 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 |
d4bf2cd6acd1927992d1aa0cfca7997886e97130916b20cc1fdbce8a059cd9b0
|
|
| MD5 |
645ea22afb198c2dd41183805298f583
|
|
| BLAKE2b-256 |
a7b134a27cf58e14a3b132024bd5534520932f54ae6bc18ae3dd69c736b91efc
|
Provenance
The following attestation bundles were made for tha_map_runner-0.1.2-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.2-py3-none-any.whl -
Subject digest:
d4bf2cd6acd1927992d1aa0cfca7997886e97130916b20cc1fdbce8a059cd9b0 - Sigstore transparency entry: 1551900989
- Sigstore integration time:
-
Permalink:
tha-guy-nate/tha-map-runner@0bd11e22d18b4e761348fc797a7336aa03ab3f27 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/tha-guy-nate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0bd11e22d18b4e761348fc797a7336aa03ab3f27 -
Trigger Event:
push
-
Statement type: