Record Convertor¶
Rule-based record transformation for Python¶
record-convertor is a library that converts input dicts into desired output formats using YAML or dict-based rule configurations. It normalizes records of the same data type from different sources into a single validated structure.
docs |
|
|---|---|
package |
Installation¶
pip install record-convertor
Quick Example¶
from record_convertor import RecordConvertorWithRulesDict
rules = {
"name": "item.name",
"brand": "item.brand.name",
"price": "item.price",
}
convertor = RecordConvertorWithRulesDict(rule_dict=rules)
input_record = {
"item": {
"name": "Widget",
"brand": {"name": "Acme"},
"price": 9.99,
}
}
result = convertor.convert(input_record)
# result: {"name": "Widget", "brand": "Acme", "price": 9.99}