Skip to main content

Recompose

Recompose is a Python package for recomposing data by following instructional schemas.

Full documentation is online at cariad.github.io/recompose.

Example

For example, the code below describes a dataset with groups of people with specific careers, and a schema that reduces the list of firefighters down to a single object.

from recompose import CursorSchema, transform

data = {
    "2023-06-04": {
        "groups": {
            "chefs": [
                {
                    "name": "Alice"
                },
                {
                    "name": "Bob"
                }
            ],
            "firefighters": [
                {
                    "name": "Daniel"
                },
                {
                    "name": "Esther"
                }
            ],
            "zookeepers": [
                {
                    "name": "Gregory"
                },
                {
                    "name": "Harold"
                }
            ]
        }
    },
    "2023-06-05": {
        "groups": {
            "chefs": [
                {
                    "name": "Jet"
                },
                {
                    "name": "Karen"
                }
            ],
            "firefighters": [
                {
                    "name": "Mater"
                },
                {
                    "name": "Nigel"
                }
            ],
            "zookeepers": [
                {
                    "name": "Peter"
                },
                {
                    "name": "Quentin"
                }
            ]
        }
    }
}

schema: CursorSchema = {
    "version": 1,
    "on": "each-value",
    "perform": {
        "path": "groups",
        "cursor": {
            "perform": {
                "path": "firefighters",
                "cursor": {
                    "perform": "list-to-object",
                }
            }
        }
    }
}

transformed = transform(schema, data)

print(transformed)
{
    "2023-06-04": {
        "groups": {
            "chefs": [
                {
                    "name": "Alice"
                },
                {
                    "name": "Bob"
                }
            ],
            "firefighters": {
                "name": "Daniel"
            },
            "zookeepers": [
                {
                    "name": "Gregory"
                },
                {
                    "name": "Harold"
                }
            ]
        }
    },
    "2023-06-05": {
        "groups": {
            "chefs": [
                {
                    "name": "Jet"
                },
                {
                    "name": "Karen"
                }
            ],
            "firefighters": {
                "name": "Mater"
            },
            "zookeepers": [
                {
                    "name": "Peter"
                },
                {
                    "name": "Quentin"
                }
            ]
        }
    }
}

Author

Hello! 👋 I'm Cariad Eccleston, and I'm a freelance Amazon Web Services architect, DevOps evangelist, and infrastructure and backend engineer by the beach in the United Kingdom.

You can find me at cariad.earth, github.com/cariad and linkedin.com/in/cariad.

Metadata

Release files for recompose 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for recompose 1.1.0
File Interpreter ABI Platform Actions
recompose-1.1.0-py3-none-any.whl Python 3 none any Details for recompose-1.1.0-py3-none-any.whl

Release files / recompose-1.1.0-py3-none-any.whl

Download URL recompose-1.1.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5575db0bcc7acfb3ba6da518b450e315433d1e38b5435ccacf5396806b4dad1
BLAKE2b-256 checksum
How to use checksums
241f56c15353e0834c2ec57eff68e85ca9ef0843349df063081630e287a2ac9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.19

Security for recompose 1.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page