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

Currently, the D.24A directory is supported. 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:

  • All source code (everything under src/) has been written manually, without AI generation.
  • 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.1.0.tar.gz (1.2 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.1.0-py3-none-any.whl (60.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for edifactlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f76a5c08b88800d4016780b1c6a22eb2bc680decf18882e795305e47c6fa4612
MD5 9952b06d8a19433f83b768d30c8d49c7
BLAKE2b-256 96db801aaca11ef1b9781a600cdce63bb02163d44ffb0399a783fd756e949946

See more details on using hashes here.

File details

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

File metadata

  • Download URL: edifactlib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 60.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f277af037a47ab9a4aed60096783f9141a87901568dd4d22df94b9bfe319b8d6
MD5 6efb2a89a3f87b31c2bd7fc53dc9b900
BLAKE2b-256 72579cc369cd502d68a32b969b0f36b10291a619880968c5945bcf749a5930d1

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