Package: ebdtable2graph
ebdtable2graph🇩🇪 Dieses Repository enthält ein Python-Paket namensebdtable2graph, 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 packageebdtable2graph.RationaleAssume, that you scraped the Entscheidungsbaumdiagramm tables by EDI@Energy from their somewhat "digitized" PDF/DOCX files.
(To do so, you can use the packageebddocx2table.)
Also assume, that the result of your scraping is aebdtable2graph.models.EbdTable.The packageebdtable2graphcontains logic to convert your scraped data into a graph.
This graph can then be exported e.g. as SVG and/or UML.How to useebdtable2graph?Install the package from pypi:pipinstallebdtable2graphCreate an Instance ofEbdTableEbdTablecontains the raw data by BDEW in a machine-readable format.
Creating instances ofEbdTableis out of scope for this package.
Ask Hochfrequenz for support on this topic.
In the following example we hard code the information.fromebdtable2graph.graph_conversionimportconvert_table_to_graphfromebdtable2graph.modelsimportEbdCheckResult,EbdTable,EbdTableMetaData,EbdTableRow,EbdTableSubRow,EbdGraphebd_table:EbdTable# this is the result of scraping the docx fileebd_table=EbdTable(# this data shouldn't be handwrittenmetadata=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,),],),],)assertisinstance(ebd_table,EbdTable)ebd_graph=convert_table_to_graph(ebd_table)assertisinstance(ebd_graph,EbdGraph)Export as PlantUMLfromebdtable2graphimportconvert_graph_to_plantumlplantuml_code=convert_graph_to_plantuml(ebd_graph)withopen("e_0003.puml","w+",encoding="utf-8")asuml_file:uml_file.write(plantuml_code)The filee_0003.pumlnow 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
@endumlExport as SVGYou can also export the graph as SVGfromebdtable2graphimportconvert_plantuml_to_svg_krokisvg_code=convert_plantuml_to_svg_kroki(plantuml_code)withopen("e_0003.svg","w+",encoding="utf-8")assvg_file:svg_file.write(svg_code)How to use this Repository on Your Machine (for development)Please follow the instructions in
ourPython Template Repository. And for further information, see theTox Repository.ContributeYou are very welcome to contribute to this template repository by opening a pull request against the main branch.Related Tools and ContextThis repository is part of theHochfrequenz Libraries and Tools for a truly digitized market communication.