skillfed

pydifact

Pydifact is a library that aims to provide complete support for reading and writing EDIFACT files. These file format, despite being old, is still a standard in many business cases. In Austria e.g., it is used for the transfer of medical reports between medical doctors.

pydifact v0.2.3 236.8K downloads/30d#8,976 on PyPI190
Permissive license MIT Active released

What it is and what it does

Pydifact is a Python port of a PHP EDIFACT library that lets you work with UN/EDIFACT interchange files—a decades-old but still widely used format for business document exchange, particularly in medical, logistics, and trading sectors. It provides three main workflows: parsing interchanges from files or strings into navigable message and segment objects; iterating directly over segments; and constructing new interchanges programmatically from scratch with custom segments.

The library handles the low-level syntax of EDIFACT (delimiters, segment markers, element separators) so you work with structured message objects instead of raw text. It has no external dependencies, installs quickly, and runs on modern Python versions. The codebase is actively maintained but still marked as Alpha, meaning the API may change—a trade-off to be aware of if you are locking this into production workflows.

Use it for:

  • Parse incoming EDIFACT purchase orders or invoices from trading partners into Python objects for validation or database import.
  • Generate EDIFACT interchanges programmatically to send standardized EDI messages to external systems.
  • Extract and transform specific segments from large EDIFACT files for reporting or data migration.
  • Build EDI middleware that reads, validates, and re-serializes EDIFACT messages between legacy and modern systems.
  • Integrate EDIFACT support into medical or logistics applications that must exchange documents with regulated partners.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Pydifact parses and serializes UN/EDIFACT interchange files, allowing you to read EDI messages from files or strings and construct them programmatically.

Yes, if you need to work with EDIFACT files in Python and can tolerate an Alpha-stage API. The library is actively maintained, has no dependencies, installs easily, and solves a real gap in the Python ecosystem. The main caveat is that the API is not yet stable—pin your version and test carefully before upgrading. If you need a production-hardened EDIFACT tool immediately, review the alternatives listed in the documentation first.

Install

pydifact on PyPI

pip

pip install pydifact

uv

uv add pydifact

poetry

poetry add pydifact

Installing pydifact

Before you install

Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a recent release; marked Alpha (Development Status 3) so the API may still shift.

License in practice

MIT license permits commercial and private use with minimal restrictions—you may use, modify, and distribute this library freely provided you include the license notice.

Quickstart

from pydifact.segmentcollection import Interchange

interchange = Interchange.from_str(
    "UNA:+,? '"
    "UNB+UNOC:1+1234+3333+200102:2212+42'"
    "UNH+42z42+PAORES:93:1:IA'"
    "MSG+1:45'"
    "UNT+5+42z42'UNZ+2+42'"
)
for message in interchange.get_messages():
    for segment in message.segments:
        print(f"Segment tag: {segment.tag}")

Requires Python 3.10 or later.

Verify before relying

  • Whether the Alpha status API instability poses a risk for production use in your context.
  • Performance characteristics when parsing very large EDIFACT files (extended tests exist but results not published).
  • Completeness of support for all UN/EDIFACT message types beyond the documented examples.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 126 days since the last release
Last repo commit
First released
Downloads 236,781/month — #8,976 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pydifact-0.2.3-py3-none-any.whl

Development Status :: 3 - AlphaEnvironment :: ConsoleIntended Audience :: DevelopersNatural Language :: EnglishOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3Topic :: Software Development :: Libraries

Tags

EDIFACT parserEDI file parsingUN/EDIFACT libraryinterchange serializationEDI message handlingsegment parsingEDIFACT interchange reader
edi-edifactdata-interchangebusiness-documents

More Libraries packages