Skip to main content

A scraper to library to scrape .docx files with 'Entscheidungsbaumdiagramm' tables into a truely machine readable structure

Project description

ebdamame

License: GPL Python Versions (officially) supported Unittests status badge Coverage status badge Linting status badge Formatting status badge PyPi Status Badge

🇩🇪 Dieses Repository enthält ein Python-Paket namens ebdamame (früher: ebddocx2table), das genutzt werden kann, um aus .docx-Dateien maschinenlesbare Tabellen, die einen Entscheidungsbaum (EBD) modellieren, zu extrahieren (scrapen). Diese Entscheidungsbäume sind Teil eines regulatorischen Regelwerks für die deutsche Energiewirtschaft und kommen in der Eingangsprüfung der Marktkommunikation zum Einsatz. Die mit diesem Paket erstellten maschinenlesbaren Tabellen können mit rebdhuhn (früher: ebdtable2graph) in echte Graphen und Diagramme umgewandelt werden. Exemplarische Ergebnisse des Scrapings finden sich als .json-Dateien im Repository machine-readable_entscheidungsbaumdiagramme.

🇬🇧 This repository contains the source code of the Python package ebdamame (formerly published as ebddocx2table).

Rationale

Assume that you want to analyse or visualize the Entscheidungsbaumdiagramme (EBD) by EDI@Energy. The website edi-energy.de, as always, only provides you with PDF or Word files instead of really digitized data.

The package ebdamame scrapes the .docx files and returns data in a model defined in the "sister" package rebdhuhn (formerly known as ebdtable2graph).

Once you scraped the data (using this package) you can plot it with rebdhuhn.

How to use the package

In any case, install the repo from PyPI:

pip install ebdamame

Use as a library

import json
from pathlib import Path

import cattrs

from ebdamame import TableNotFoundError, get_all_ebd_keys, get_ebd_docx_tables  # type:ignore[import]
from ebdamame.docxtableconverter import DocxTableConverter  # type:ignore[import]

docx_file_path = Path("unittests/test_data/ebd20230629_v34.docx")
# download this .docx File from edi-energy.de or find it in the unittests of this repository.
# https://github.com/Hochfrequenz/ebddocx2table/blob/main/unittests/test_data/ebd20230629_v34.docx
docx_tables = get_ebd_docx_tables(docx_file_path, ebd_key="E_0003")
converter = DocxTableConverter(
    docx_tables,
    ebd_key="E_0003",
    chapter="MaBiS",
    sub_chapter="7.42.1: AD: Bestellung der Aggregationsebene der Bilanzkreissummenzeitreihe auf Ebene der Regelzone",
)
result = converter.convert_docx_tables_to_ebd_table()
with open(Path("E_0003.json"), "w+", encoding="utf-8") as result_file:
    # the result file can be found here:
    # https://github.com/Hochfrequenz/machine-readable_entscheidungsbaumdiagramme/tree/main/FV2310
    json.dump(cattrs.unstructure(result), result_file, ensure_ascii=False, indent=2, sort_keys=True)

Use as a CLI tool

to be written

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.

Related Tools and Context

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ebdamame-0.2.2.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

ebdamame-0.2.2-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file ebdamame-0.2.2.tar.gz.

File metadata

  • Download URL: ebdamame-0.2.2.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ebdamame-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b8e9d0ee13edddf1209449ce91a74c0b6fdba4ff48a8fd41ce3e218995b58b86
MD5 2bfb181b7a730c01d794d56019308396
BLAKE2b-256 7e52a299a66d41666004ca34a81d670e33a72be2d838c4cb9372dafee49010bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for ebdamame-0.2.2.tar.gz:

Publisher: python-publish.yml on Hochfrequenz/ebdamame

Attestations:

File details

Details for the file ebdamame-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: ebdamame-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for ebdamame-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2043bc7883d500033a33d1b1edb4d1e2d4c6e6e8235a3b37e320de7d69bee70
MD5 8d80cbcbcb8134c5cce133c6ad3ef28f
BLAKE2b-256 ca238e527bc417e98ad47f2d06bc3ea4253dbffdc7a1f3128cc2b299bf33207b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ebdamame-0.2.2-py3-none-any.whl:

Publisher: python-publish.yml on Hochfrequenz/ebdamame

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page