Skip to main content

No project description provided

Project description

edifactlib

A Python package for parsing, validating, and inspecting EDIFACT interchanges. It comes both with a CLI tool for inspecting EDIFACT files directly from the terminal, and with a regular Python library for use in code.

Installation

pip install edifactlib

Usage

As a Python library

from edifactlib import Parser, InterchangeResolver

message = """
UNA:+.? '
UNB+UNOC:3+5412345000013:14+4012345000006:14+260704:1200+REF00001'
UNH+1+ORDERS:D:24A:UN'
BGM+220+PO123456+9'
DTM+137:20260704:102'
NAD+BY+5412345000013::9'
NAD+SU+4012345000006::9'
LIN+1++4712345:EN'
QTY+21:100'
LIN+2++4798765:EN'
QTY+21:50'
UNS+S'
UNT+11+1'
UNZ+1+REF00001'
"""

parser = Parser()
interchange = parser.parse(message)

resolver = InterchangeResolver()
resolver.resolve(interchange)

Parser turns the raw EDIFACT message as an Interchange model (segments, data elements, components) and validates it against the corresponding EDIFACT directory by default (pass validate=False to parser.parse(...) to skip validation). InterchangeResolver then enriches the parsed data with the names/descriptions from the directory.

Command line

After installation, the edifact command is available.

Read and inspect an EDIFACT file:

edifact /path/to/message.edi

Alternatively, pass the message directly as a string:

edifact --from-string "UNA:+.? 'UNB+UNOC:3+...'"

The interchange header, contained messages, and functional groups are printed to the console in a formatted view:

CLI output as a formatted tree

Pass --print-json to print the parsed interchange as JSON instead, e.g. for piping into other tools:

edifact /path/to/message.edi --print-json

CLI output as JSON

Supported EDIFACT versions and directories

EDIFACT version

Currently version 2 and 3 are supported. An implementation for version 4 is planned.

Directories

The following directories are currently supported:

  • D.24A
  • D.23A
  • D.22B
  • D.22A
  • D.21B
  • D.21A

Older directories will follow.

Transparency regarding AI-generated content

This project values transparency about which content was hand-written and which was created with AI assistance:

  • Source code under src/ is mainly hand-written. Any AI-generated portions are explicitly marked as such.
  • Exception: the tests folder. Test code is created with AI assistance.
  • Any AI-generated code within the tests folder is marked as such with a corresponding comment in the code.
  • If a file in the tests folder does not contain such a marker comment, its content was written manually.
  • The README.MD file was mostly generated by AI.

Status

This project is under active development. The API may still change before the first stable release.

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

edifactlib-0.2.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

edifactlib-0.2.0-py3-none-any.whl (158.6 kB view details)

Uploaded Python 3

File details

Details for the file edifactlib-0.2.0.tar.gz.

File metadata

  • Download URL: edifactlib-0.2.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for edifactlib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 81ab7f68c3df1b88b50ba20158f47f822735da60f965e99905c7cfc2475ab98c
MD5 3df27dceb121e3984047f2a3333113aa
BLAKE2b-256 9115ab0e63201ffe349d6221b92b003ed65cbd0e6328ee7778951f1778d124e0

See more details on using hashes here.

File details

Details for the file edifactlib-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: edifactlib-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 158.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for edifactlib-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9eb29d040e2a4b96568377300536d34cf62855d5cddd8ab3705c83234c0b6b1
MD5 cda9cdf49074348cc25e977f7b8b9594
BLAKE2b-256 9440bcdbdc5b85679ae1988b52e872c6019d5169395775cf088f122067d52745

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