--- id: pydifact version: "0.2.3" license: MIT license_treatment: permissive maintenance: active --- # 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. License: permissive · Maintenance: active · Downloads: 236.8K/mo ## 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 above — 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 pip install pydifact uv add pydifact 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_current - Install friction: low - Maintenance: active - Downloads: 236.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags EDIFACT parser, EDI file parsing, UN/EDIFACT library, interchange serialization, EDI message handling, segment parsing, EDIFACT interchange reader, edi-edifact, data-interchange, business-documents [View on SkillFed](https://skillfed.io/packages/pydifact) · [View on PyPI](https://pypi.org/project/pydifact/)