Skip to main content

ebdtable2graph

Unittests status badge Coverage status badge Linting status badge Black status badge PyPi Status Badge

🇩🇪 Dieses Repository enthält ein Python-Paket namens ebdtable2graph, das genutzt werden kann, um aus .docx-Dateien extrahierte maschinenlesbare Tabellen, die einen Entscheidungsbaum (EBD) modellieren, in echte Graphen zu konvertieren. Diese Entscheidungsbäume sind Teil eines regulatorischen Regelwerks für die deutsche Energiewirtschaft und kommen in der Eingangsprüfung der Marktkommunikation zum Einsatz.

🇬🇧 This repository contains the source code of the Python package ebdtable2graph.

Rationale

Assume, that you scraped the Entscheidungsbaumdiagramm tables by EDI@Energy from their somewhat "digitized" PDF/DOCX files. (To do so, you can use the package ebddocx2table.) Also assume, that the result of your scraping is a ebdtable2graph.models.EbdTable.

The package ebdtable2graph contains logic to convert your scraped data into a graph. This graph can then be exported e.g. as SVG and/or UML.

How to use ebdtable2graph?

Install the package from pypi:

pip install ebdtable2graph

Create an Instance of EbdTable

EbdTable contains the raw data by BDEW in a machine-readable format. Creating instances of EbdTable is out of scope for this package. Ask Hochfrequenz for support on this topic. In the following example we hard code the information.

from ebdtable2graph.graph_conversion import convert_table_to_graph
from ebdtable2graph.models import EbdCheckResult, EbdTable, EbdTableMetaData, EbdTableRow, EbdTableSubRow, EbdGraph

ebd_table: EbdTable  # this is the result of scraping the docx file
ebd_table = EbdTable(  # this data shouldn't be handwritten
    metadata=EbdTableMetaData(
        ebd_code="E_0003",
        chapter="7.39 AD: Bestellung der Aggregationsebene der Bilanzkreissummenzeitreihe auf Ebene der Regelzone",
        sub_chapter="7.39.1 E_0003_Bestellung der Aggregationsebene RZ prüfen",
        role="ÜNB",
    ),
    rows=[
        EbdTableRow(
            step_number="1",
            description="Erfolgt der Eingang der Bestellung fristgerecht?",
            sub_rows=[
                EbdTableSubRow(
                    check_result=EbdCheckResult(result=False, subsequent_step_number=None),
                    result_code="A01",
                    note="Fristüberschreitung",
                ),
                EbdTableSubRow(
                    check_result=EbdCheckResult(result=True, subsequent_step_number="2"),
                    result_code=None,
                    note=None,
                ),
            ],
        ),
        EbdTableRow(
            step_number="2",
            description="Erfolgt die Bestellung zum Monatsersten 00:00 Uhr?",
            sub_rows=[
                EbdTableSubRow(
                    check_result=EbdCheckResult(result=False, subsequent_step_number=None),
                    result_code="A02",
                    note="Gewählter Zeitpunkt nicht zulässig",
                ),
                EbdTableSubRow(
                    check_result=EbdCheckResult(result=True, subsequent_step_number="Ende"),
                    result_code=None,
                    note=None,
                ),
            ],
        ),
    ],
)
assert isinstance(ebd_table, EbdTable)

ebd_graph = convert_table_to_graph(ebd_table)
assert isinstance(ebd_graph, EbdGraph)

Export as PlantUML

from ebdtable2graph import convert_graph_to_plantuml

plantuml_code = convert_graph_to_plantuml(ebd_graph)
with open("e_0003.puml", "w+", encoding="utf-8") as uml_file:
    uml_file.write(plantuml_code)

The file e_0003.puml now looks like this:

@startuml
...
if (<b>1: </b> Erfolgt der Eingang der Bestellung fristgerecht?) then (ja)
else (nein)
    :A01;
    note left
        Fristüberschreitung
    endnote
    kill;
endif
if (<b>2: </b> Erfolgt die Bestellung zum Monatsersten 00:00 Uhr?) then (ja)
    end
else (nein)
    :A02;
    note left
        Gewählter Zeitpunkt nicht zulässig
    endnote
    kill;
endif
@enduml

Export as SVG

You can also export the graph as SVG

from ebdtable2graph import convert_plantuml_to_svg_kroki

svg_code = convert_plantuml_to_svg_kroki(plantuml_code)
with open("e_0003.svg", "w+", encoding="utf-8") as svg_file:
    svg_file.write(svg_code)

How to use this Repository on Your Machine (for development)

Please follow the instructions in our Python Template Repository . And for further information, see the Tox Repository.

Contribute

You are very welcome to contribute to this template repository by opening a pull request against the main branch.

This repository is part of the Hochfrequenz Libraries and Tools for a truly digitized market communication.

Metadata

Release files for ebdtable2graph 0.1.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ebdtable2graph 0.1.20
File Size Uploaded Provenance
ebdtable2graph-0.1.20.tar.gz 130.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ebdtable2graph 0.1.20
File Interpreter ABI Platform
ebdtable2graph-0.1.20-py3-none-any.whl Python 3 none any Details

Total release size: 166.9 kB

Release files / ebdtable2graph-0.1.20.tar.gz

Download URL ebdtable2graph-0.1.20.tar.gz
Size 130.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0dc70fc260a085a788c4d56a310ab4c328928ed5c055c23804b0f809d8a36526
BLAKE2b-256 checksum
How to use checksums
d6e89d7ed3375f346c1afb7c8ad9d9be48e5f922ad1da8ca5f69660891bf69d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / ebdtable2graph-0.1.20-py3-none-any.whl

Download URL ebdtable2graph-0.1.20-py3-none-any.whl
Size 36.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2258106910e4264eac8013548538e40dfda3f77f1b5cb3dce9db1f8eda32106b
BLAKE2b-256 checksum
How to use checksums
667b0455b6eeb7dccc2d093f0ef793ba625986683ee34fb1e026ad2883513338
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for ebdtable2graph 0.1.20

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page