Skip to main content

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


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)

Uploaded Source

Built Distribution

magicmapper-0.9.1-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

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