Skip to main content

No project description provided

Project description

detakon

PyPI - Version PyPI - Python Version


Description

A data converter than uses configuration maps (referred to as detamaps) to map fields in the source data to output data, and perform operations on the data before outputting. Detamaps may also contain configuration data for the data source and output, and defaults to use if fields are missing, or blank/empty.

[!NOTE] Detakon is in early development and may have breaking changes between versions. Detamaps, methods, and usage may change between minor versions until version 1.0 release. After version 1.0 release, any breaking changes will result in a major version bump. Recommended to use PyPI version. Version in source code is next planned release on PyPI, and is not official until pushed to PyPI.

Table of Contents

Installation

pip install detakon

Usage

[!WARNING] Status: Currently in pre-release, as minimal viable product for CSV to CSV conversions only. Not for usage in production systems, breaking changes are coming in future releases. Some planned changes can be viewed in the ROADMAP.md file.

Detakon(detamap, source, destination)

Sample:

from detakon import Detakon

converter = Detakon("invoice_detamap.json", "data_dump_2026-01-01.csv", "invoice_2026-01-01.csv")
converter.convert()

Detamap Files

A detamap configuration file is used to provide all details necessary for the data conversion.

A datamap must be a Python dictionary, or convertable to a Python dictionary. Currently this means either a dictionary or JSON file (plans to add TOML support).

A detamap MUST include the following key:value pairs:

  • "Mappings" with a sub-dictionary of source data field names as keys, mapped to output field names as values.
  • "Defaults" with a sub-dictionary of source field names that will supply a default value if either: (not currently implemented)
    • Matching field was not found in source.
    • Matching source data was empty, such as an empty string.
  • "Operations" with a sub-dictionary of operations to perform on output data: (not currently implemented)
    • Example opersations may be "upper", or "convertValue".
  • "Source" with a sub-dictionary that defines the type of source being passed, and the arguments to pass to Path.open() if source is a file, or csv.DictReader if source is CSV data.
    • Required keys:
      • "argument" as type of argument being passed as the source argument to the Detakon initializer. Accepted values: "filepath".
        • "type" key may be required depending on the argument being passed.
  • "Output" with a sub-dictionary that defines the type of output expected, and the arguments to pass to Path.open() if destination is a file, or csv.DictReader if output is CSV data.
    • "fields" sub-key as a list of strings corresponding to the output field names in the desired order.

A detamap JSON file may look similar to:

{
    "Mappings": {
        "Invoice #": "External Order ID",
        "Client Last Name": "Last Name",
        "Client First Name": "First Name",
        "Date of Birth": "DOB"
    },
    "Defaults": {
        "DOB": "Unknown"
    },
    "Operations": {
        "upper": ["External Order ID", "Last Name", "First Name"]
    },
    "Source": {
        "argument": "filepath",
        "type": "str",
        "encoding": "utf-8",
        "format": "csv",
        "delimiter": ","
    },
    "Output": {
        "fields": ["External Order ID", "Last Name", "First Name", "DOB"],
        "argument": "filepath",
        "type": "str",
        "append": false,
        "omit_heading": false,
        "encoding": "utf-8",
        "format": "csv",
        "delimiter": ","
    }
}

Above sample is not all-inclusive. Detamaps, source data, and output expect full chain of custody. No security guarantees are made. Users are advised not to use untrusted, or malformed data.

License

detakon is distributed under the terms of the MIT license.

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

detakon-0.0.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

detakon-0.0.4-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file detakon-0.0.4.tar.gz.

File metadata

  • Download URL: detakon-0.0.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.11.2 HTTPX/0.28.1

File hashes

Hashes for detakon-0.0.4.tar.gz
Algorithm Hash digest
SHA256 93e261faf2b9a05a71e4dda63197a3813bd81ad807a957921f7d4b1df15528f1
MD5 9be4fbbdc0035397c3e4111871b29dca
BLAKE2b-256 4e99962d460e4310a594b654c27f50c4e3e22ddbb5363bffab29f596a4d700bd

See more details on using hashes here.

File details

Details for the file detakon-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: detakon-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.11.2 HTTPX/0.28.1

File hashes

Hashes for detakon-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 088ea151199a8283df79277b10628df59797a593656aaa0630bc9874c12374bb
MD5 8627ce44ee554c6b420f658742e8ce0a
BLAKE2b-256 38760c248024ed64c7e94ff2e27bfc085491e9c30bcf780ccd44eff386a75718

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