Skip to main content

No project description provided

Project description

detakon

PyPI - Version PyPI - Python Version


Table of Contents

Installation

NOTE: Currently in pre-release. Current status is: Minimal viable product for CSV to CSV conversions only. Not for usage in production systems.

pip install detakon

Usage

Detakon(detamap, source, destination)

Sample:

from detakon import Detakon

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

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:

  • "Fields" as a list of strings corresponding to the output field names in the desired order.
  • "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 output 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.

A detamap JSON file may look similar to:

{
    "Fields": ["External Order ID", "Last Name", "First Name", "DOB"],
    "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": {
        "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.3.tar.gz (7.0 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.3-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: detakon-0.0.3.tar.gz
  • Upload date:
  • Size: 7.0 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.3.tar.gz
Algorithm Hash digest
SHA256 30c4b2c56e6db03b81dc9d4aece102ca5a1a632aa8548b1fcf864370cfba9170
MD5 3eb89e32cb93356a278ef6acd77fe61e
BLAKE2b-256 71db1a74a4ffcd3ab7e5f8dc24c2eb2a029b9ead007dcca119cdcaabd990fae4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: detakon-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d6755192fc76d7dee0886c3bf4c6646b79cbdd10cffffbe15f4b8a060545517e
MD5 2a7bd32af8882538c425f6eb68e1c461
BLAKE2b-256 bbac73a57e44b9e4a88f4ea3be264315c657a984370af4e1f4366902d928d192

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