Skip to main content

Converts structure, keys and fields from a record according to predefined rules

Project description

PyPI Package latest release Supported versions Documentation Status

A rule-based record transformation library for Python. Converts input dicts into desired output formats using YAML or dict-based rule configurations. Designed to normalize records of the same data type from different sources into a single validated structure.

Features

  • Map fields using simple dot-separated string paths for nested access (literal keys, no quoting needed)

  • Transform field values in-place with 25+ built-in conversion actions (string ops, math, URL cleanup, phone parsing, etc.)

  • Compute output values with command processors (GeoJSON points, joins, splits, list transforms)

  • Convert between date formats (Unix timestamps, DD-MM-YYYY, YYYY_MM_DD, etc.)

  • Run records through Pydantic models or dataclasses with optional method invocation

  • Conditionally execute rules or skip entire records

  • Extend with custom field convertors, date formatters, and command classes via protocols

Installation

pip install record-convertor

Quick Start

from record_convertor import RecordConvertorWithRulesDict

rules = {
    "name": "item.name",
    "brand": "item.brand.name",
    "price": "item.price",
}

convertor = RecordConvertorWithRulesDict(rule_dict=rules)

result = convertor.convert({
    "item": {
        "name": "Widget",
        "brand": {"name": "Acme"},
        "price": 9.99,
    }
})
# {"name": "Widget", "brand": "Acme", "price": 9.99}

Documentation

Full documentation is available at https://record-convertor.readthedocs.io/

License

LGPL-3.0-or-later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

record_convertor-1.3.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

record_convertor-1.3.0-py3-none-any.whl (48.7 kB view details)

Uploaded Python 3

File details

Details for the file record_convertor-1.3.0.tar.gz.

File metadata

  • Download URL: record_convertor-1.3.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for record_convertor-1.3.0.tar.gz
Algorithm Hash digest
SHA256 adc9bb237f950962e99c547b50126bdcf78f7a32e00ef72e9696f3a4d65a9317
MD5 2a8cc29297b0d588c706e30c90daab76
BLAKE2b-256 646c80d80a5332487a63dc5a5a9b81d0b4ef4b2c4792f4108cf3adaeadd89da3

See more details on using hashes here.

File details

Details for the file record_convertor-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: record_convertor-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 48.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for record_convertor-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d2a33f18bfff2884754d72baf36759121a4b8bc6a3056afdfc4229acd1f9961
MD5 3c85cdbb0382f6f7246b4c7484df7cd5
BLAKE2b-256 f5d60f9aa82f34f0fbc932b618381c82d5687110538a78d21f21f8f22bbc52e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page