mapmonkey
Fuzzy column mapping between source and target schemas. Source has
First Name, target needs first_name; two files have Customer ID vs
customer_id vs CustomerID vs cust_id. mapmonkey suggests the mapping with
confidence scores, lets you save and reuse it, validates it against real
schemas, and applies the renames (and value rewrites) to your data.
Part of the monkey toolkit. MIT licensed.
Install
pip install mapmonkey
Depends on cleanmonkey (invisible
character / whitespace normalization) and PyYAML.
Quick start
from mapmonkey import suggest, apply_map, save_mapping, load_mapping
source = ["First Name", "Last Name", "Customer ID", "qty"]
target = ["first_name", "last_name", "customer_id", "quantity"]
suggestion = suggest(source, target)
for m in suggestion.matches:
print(f"{m.source} -> {m.target} ({m.confidence:.2f}, {m.reason})")
# First Name -> first_name (0.95, normalized)
# Customer ID -> customer_id (0.95, normalized)
# qty -> quantity (0.95, abbreviation)
mapping = suggestion.to_mapping()
save_mapping(mapping, "customers.yaml") # reuse it later
rows = [{"First Name": "Ann", "qty": "3"}]
apply_map(rows, load_mapping("customers.yaml"))
# [{'first_name': 'Ann', 'quantity': '3'}]
What it does
- Auto-suggest mappings —
suggest(source, target)returns matches with confidence scores in[0, 1]and a reason (exact,normalized,abbreviation,fuzzy). - Normalization engine —
normalize("CustomerID") == "customer id". Collapses case, separators, camelCase, digit boundaries and abbreviations. - Abbreviation dictionary — safe defaults (
qty->quantity,dob->date of birth, ...). Risky short words (min,long,st) are opt-in viabuild_table(aggressive=True); extend withbuild_table({"abbr": "expansion"}). - Mapping persistence —
save_mapping/load_mappingas YAML or JSON, chosen by file extension. Round-trips are lossless. - Validation —
validate(mapping, source_columns=, target_columns=)reports unmapped, stale, and colliding columns. - Apply —
apply_map(data, mapping)renames columns onlist[dict]records ordict[str, list]columnar data; unmapped columns pass through. - Value mapping —
detect_value_map(["M", "F"]) == {"M": "Male", "F": "Female"};apply_value_map(values, vmap)rewrites cells, keeping unknown values.
CLI
mapmonkey suggest --source a.csv --target b.csv --out map.yaml
mapmonkey apply --map map.yaml --input a.csv --output renamed.csv
mapmonkey validate --map map.yaml --source a.csv --target b.csv
suggest also accepts --source-cols "a,b,c" instead of a file, a
--threshold, and --interactive to confirm each match.
Using with AI assistants
See SKILL.md for an LLM-consumable quick reference (decision
tree, worked examples, troubleshooting). See LIMITATIONS.md
for deliberate design tradeoffs before "fixing" surprising behaviour.
Development & review
See CONTRIBUTING.md for the testing philosophy and the
competitive multi-model review process. The release decision is rubric-based:
RELEASE_READINESS.md defines the gates and score, and
python scripts/readiness.py computes it (history in
REVIEW_HISTORY.md).
Scope
In scope: column-name matching, fuzzy matching, abbreviation expansion,
mapping persistence, value mapping. Out of scope: data transformation beyond
renaming and type conversion (use typemonkey).
Metadata
Release files for mapmonkey 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mapmonkey-1.1.1.tar.gz | 50.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mapmonkey-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 79.5 kB
Release files / mapmonkey-1.1.1.tar.gz
| Download URL | mapmonkey-1.1.1.tar.gz |
|---|---|
| Size | 50.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75ec01973335b7bc9771071cd013b04fe0dfcc3ea5eb2bf2c1c6c180ef3d2539
|
|
BLAKE2b-256 checksum How to use checksums |
4202b4c0c7ee12a0438327e09e561f56fdbb2452e8e6619e6eca176ae90e79d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / mapmonkey-1.1.1-py3-none-any.whl
| Download URL | mapmonkey-1.1.1-py3-none-any.whl |
|---|---|
| Size | 29.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
340de856d020b14962826ea3707b829718ac5cdca5d5abe43fa415b2a2c409e5
|
|
BLAKE2b-256 checksum How to use checksums |
eec12b3185dde4b4ea47baab34ed89902b67325ca1e22176ee3546bcb5c034ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for mapmonkey 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.