kohlr_AHB_i
Kohlr_AHB_i generates machine-readable files from AHB documents. Kohlr_AHB_i's sister is MIG_mose.
If you'd like to create a nice diff view of AHBs in different versions, try ahlbatross.
If you're looking for a tool to process the official BDEW XMLs for AHBs (available since 2024), checkout fundamend.
Rationale
German utilities exchange data using EDIFACT; This is called market communication (mako).
The Forum Datenformate of the BDEW publishes the technical regulations of the EDIFACT based market communication on edi-energy.de.
These rules are not stable but change twice a year (in theory) or few times per year (in reality).
Specific rules, which are binding for every German utility are kind of formalised in so called "Anwendungshandbüchern" (AHB). Those AHBs are basically long tables that describe:
As a utility, if I want to exchange data about business process XYZ with a market partner, then I have to provide the following information: [...]
In total the regulations from these Anwendungshandbücher span several thousand pages. And by pages, we really mean pages. EDIFACT communication is basically the API between German utilities for most of their B2B processes. However, the technical specifications of this API are
- prose
- on DIN A4 pages.
The Anwendungshandbücher are the epitome of digitization with some good intentions.
Although the AHBs are publicly available as PDF or Word files on edi-energy.de, they are hardly accessible in a technical sense:
- You cannot automatically extract information from the AHBs.
- You cannot run automatic comparisons between different versions.
- You cannot automatically test your own API against the set of rules, described in the AHBs (as prose).
- You cannot view or visualize the information from the AHBs in any more intuitive or practical way, than the raw tables from the AHB files.
- ...any many more...
The root cause for all these inaccessibility is a technical one: Information that are theoretically structured are published in an unstructured format (PDF or Word), which is not suited for technical specifications in IT.
Kohlr_AHB_i as a tool helps you to break those chains and access the AHBs as you'd expect it from technical specs: easy and automatically instead of with hours of mindless manual work.
Kohlr_AHB_i takes the .docx files published by edi-energy.de as an input and returns truly machine-readable data in a variety of formats (JSON, CSV...) as a result.
Hence, Kohlr_AHB_i is the key for unlocking any automation potential that is reliant on information hidden in the Anwendungshandbücher.
We're all hoping for the day of true digitization on which this repository will become obsolete. Update 2025: Indeed the machine-readable (XML) MIGs and AHBs available in a paid BDEW subscription make lots of the kohlrahbi features obsolete 🎉. Still, some issues remain:
- The XML AHBs do not contain an "Änderungshistorie" although with some work you could compute them from the XMLs (more of a ahlbatross feature)
- Kohlr_AHB_i generates the data model for the AHB Tabellen web application.
Installation
Kohlr_AHB_i is a Python based tool. Therefore you have to make sure, that Python is running on your machine.
We recommend to use virtual environments to keep your system clean.
Create a new virtual environment with
python -m venv .venv
The activation of the virtual environment depends on your used OS.
Windows
.venv\Scripts\activate
MacOS/Linux
source .venv/bin/activate
Finally, install the package with
pip install kohlrahbi
Usage
Kohlrahbi is a command line tool. Run kohlrahbi --help to see all available commands.
kohlrahbi --help
Commands overview
| Command | Description |
|---|---|
kohlrahbi ahb |
Extract AHB tables from .docx files |
kohlrahbi conditions |
Extract conditions and packages from .docx files |
kohlrahbi changehistory docx |
Extract change histories from .docx files |
kohlrahbi changehistory bnetza |
Download documents from a BNetzA URL and extract change histories |
kohlrahbi ahb — Extract AHB tables
[!NOTE] This command requires a local clone of the edi_energy_mirror repository, which contains the
.docxfiles of the AHBs. The folder structure should look like this:. ├── edi_energy_mirror └── kohlrahbi
Extract all AHB tables for a specific format version:
kohlrahbi ahb -eemp ../edi_energy_mirror/ --output-path ./output/ --file-type csv --format-version FV2310
Extract tables for specific Prüfidentifikatoren:
kohlrahbi ahb -eemp ../edi_energy_mirror/ --output-path ./output/ --file-type csv --pruefis 13002 --format-version FV2310
You can provide multiple --pruefis and multiple --file-type values:
kohlrahbi ahb -eemp ../edi_energy_mirror/ --output-path ./output/ \
--file-type csv --file-type xlsx --file-type flatahb \
--pruefis 13002 --pruefis 13003 --pruefis 13005 \
--format-version FV2310
To remove old output files for Prüfidentifikatoren that no longer appear in the input, add --clear-output-path:
kohlrahbi ahb -eemp ../edi_energy_mirror/ --output-path ./output/ --file-type csv --format-version FV2310 --clear-output-path
kohlrahbi conditions — Extract conditions and packages
[!NOTE] This command also requires a local clone of the edi_energy_mirror.
kohlrahbi conditions -eemp ../edi_energy_mirror/ --output-path ./output/ --format-version FV2310
This extracts all conditions and packages found in all AHBs (including the condition texts from package tables) within the .docx files. The output is saved per EDIFACT format as conditions.json and packages.json.
[!NOTE] The conditions collected here may be more comprehensive than those collected via
kohlrahbi ahb, becauseconditionsuses a different extraction routine.
kohlrahbi changehistory — Extract change histories
The changehistory command has two subcommands depending on your data source.
kohlrahbi changehistory docx — From .docx files
[!NOTE] This command requires a local clone of the edi_energy_mirror.
kohlrahbi changehistory docx -eemp ../edi_energy_mirror/ --output-path ./output/ --format-version FV2310
kohlrahbi changehistory bnetza — From BNetzA documents
Downloads all linked documents from a BNetzA "Mitteilung" URL, extracts the change history
(Änderungshistorie) tables, and writes one Excel sheet per document.
It handles every document the page links, not just PDFs: newer pages serve most EDIFACT
documents as .html-named downloads (whose body is actually a PDF) and some as Office files.
Each file's real type is detected from its content, so nothing is skipped because of its URL
extension.
kohlrahbi changehistory bnetza \
--url "https://www.bundesnetzagentur.de/DE/Beschlusskammern/BK06/BK6_83_Zug_Mess/835_mitteilungen_datenformate/Mitteilung_55/Mitteilung_Nr_55.html" \
--output-path ./output/
The downloaded documents are saved to <output-path>/pdfs/ and the resulting Excel file to
<output-path>/change_history.xlsx. On completion a summary reports how many links were found,
how many documents were downloaded (by type), how many sheets were written, and which documents
contained no change history.
.docx Data Sources
Kohlr_AHB_i internally relies on a specific naming schema of the .docx files in which the file name holds information about the edifact format and validity period of the AHBs contained within the file.
The easiest way to be compliant with this naming schema is to clone our edi_energy_mirror repository to your localhost.
Results
There is a kohlr_AHB_i based CI pipeline from the edi_energy_mirror mentioned above to the repository machine-readable_anwendungshandbuecher where you can find scraped AHBs as JSON, CSV or Excel files.
Workflow
flowchart TB
S[Start] --> RD[Read docx]
RD --> RPT[Read all paragraphs <br> and tables]
RPT --> I[Start iterating]
I --> NI[Read next item]
%% check for text paragraph %%
NI --> CTP{Text Paragraph?}
CTP -- Yes --> NI
CTP -- No --> CCST{Is item just<br>Chapter or Section Title?}
CCST -- Yes --> CTAenderunghistorie{Is Chapter Title<br>'Änderungshistorie'?}
CTAenderunghistorie -- Yes --> EXPORT[Export Extract]
CCST -- No --> CT{Is item a table<br>with prüfis?}
CT -- Yes --> Extract[Create Extract]
AHB page number per Format
The following table shows the page number of the AHBs for each format of the format version FV2310.
| Format | Page number | Hint | |
|---|---|---|---|
| UTILMD Strom | 1064 | ||
| UTILMD Gas | 345 | ||
| REQOTE | 264 | together with QUOTES, ORDERS, ORDRSP, ORDCHG | |
| QUOTES | 264 | together with REQOTE, ORDERS, ORDRSP, ORDCHG | |
| ORDRSP | 264 | together with REQOTE, QUOTES, ORDERS, ORDCHG | |
| ORDERS | 264 | together with REQOTE, QUOTES, ORDRSP, ORDCHG | |
| ORDCHG | 264 | together with REQOTE, QUOTES, ORDERS, ORDRSP | |
| MSCONS | 164 | ||
| UTILMD MaBis | 133 | ||
| REMADV | 91 | together with INVOIC | |
| INVOIC | 91 | together with REMADV | |
| IFTSTA | 82 | ||
| CONTRL | 72 | together with APERAK, contains no Prüfis | |
| APERAK | 72 | together with CONTRL, contains no Prüfis | |
| PARTIN | 69 | ||
| UTILTS | 34 | ||
| ORDRSP | 30 | together with ORDERS | |
| ORDERS | 30 | together with ORDRSP | |
| PRICAT | 25 | ||
| COMDIS | 10 | good test for tables which are above change history |
Development
This project uses uv to manage dependencies and the development environment.
Setup
To set up the development environment, install uv and sync the dev dependency group.
uv sync --group dev
This creates a .venv and installs the package together with all development tools (tests, linting, type checking, formatting, spelling).
Run tests, linters and other checks
uv run --group test pytest --cov kohlrahbi --cov-report term-missing --cov-fail-under 79
uv run --group lint ruff check src/kohlrahbi
uv run --group typecheck mypy src/kohlrahbi unittests --strict
uv run --group lint ruff format --check src/kohlrahbi unittests
uv run --group spelling codespell src/kohlrahbi README.md
See our Python Template Repository for detailed explanations.
Contribute
You are very welcome to contribute to this template repository by opening a pull request against the main branch.
Related Tools and Context
This repository is part of the Hochfrequenz Libraries and Tools for a truly digitized market communication.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kohlrahbi-1.13.1.tar.gz.
File metadata
- Download URL: kohlrahbi-1.13.1.tar.gz
- Upload date:
- Size: 505.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea1f5796ecf369560e84993428051b6c011eada4be037a24223b94388805a178
|
|
| MD5 |
75b8ec88afb4ff36a1d7218db3d533f5
|
|
| BLAKE2b-256 |
f4bdf8d7b7d82a36d16043f8155a2c648e27f11aa3e4a78ac8b6e75b8a8ac37e
|
Provenance
The following attestation bundles were made for kohlrahbi-1.13.1.tar.gz:
Publisher:
python-publish.yml on Hochfrequenz/kohlrahbi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kohlrahbi-1.13.1.tar.gz -
Subject digest:
ea1f5796ecf369560e84993428051b6c011eada4be037a24223b94388805a178 - Sigstore transparency entry: 2306697896
- Sigstore integration time:
-
Permalink:
Hochfrequenz/kohlrahbi@0d631299f6e9fb03b8e6bb44d6183ea1c9f88fe8 -
Branch / Tag:
refs/tags/v1.13.1 - Owner: https://github.com/Hochfrequenz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0d631299f6e9fb03b8e6bb44d6183ea1c9f88fe8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kohlrahbi-1.13.1-py3-none-any.whl.
File metadata
- Download URL: kohlrahbi-1.13.1-py3-none-any.whl
- Upload date:
- Size: 116.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2faa8c873afc5508d6ec939dbdd4f3ed28286685c366983bebe923f4b48e5448
|
|
| MD5 |
a5c971ca87bbbb6544f9534451934c8e
|
|
| BLAKE2b-256 |
aeb388a3d9d62f8bd4db24ee7204356c838cc478f65a483e789379f456dfb63b
|
Provenance
The following attestation bundles were made for kohlrahbi-1.13.1-py3-none-any.whl:
Publisher:
python-publish.yml on Hochfrequenz/kohlrahbi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kohlrahbi-1.13.1-py3-none-any.whl -
Subject digest:
2faa8c873afc5508d6ec939dbdd4f3ed28286685c366983bebe923f4b48e5448 - Sigstore transparency entry: 2306697993
- Sigstore integration time:
-
Permalink:
Hochfrequenz/kohlrahbi@0d631299f6e9fb03b8e6bb44d6183ea1c9f88fe8 -
Branch / Tag:
refs/tags/v1.13.1 - Owner: https://github.com/Hochfrequenz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0d631299f6e9fb03b8e6bb44d6183ea1c9f88fe8 -
Trigger Event:
release
-
Statement type: