Mapping data structures
Project description
Magicmapper
Unconventional (?) approach to mapping data from one object to another.
Usage
Check out test_magic.py for some examples. The fundamental idea is that we define a target schema which we can populate using the magicmapper. Consider the following source data
source_data = [
{
"person": {
"name": "foo1"
}
},
{
"person": {
"name": "foo2"
}
},
]
Say we'd like to map this to this
destination_data = [
{
"name": "foo1"
},
{
"name": "foo2"
},
]
This could be done with the following magicmapping
from magicmapper import magic_map, Schema, Value
magic_map([Schema({"name": Value("person") >> Value("name")})], test_source_data)
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
magicmapper-0.9.1.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for magicmapper-0.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e9d9d19717a4840cbf024d0846e205746f389cd094f9c9b1fbb295550a88f01 |
|
MD5 | 2c47e9dd17c5314b580813f4a6646bfe |
|
BLAKE2b-256 | eba6ace9ea47bc61460d381e9bb9c6552bbca865e1b76c7e95b48c6743f23dea |