Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Initial PR #5

Merged
merged 131 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
a6b7f5c
🚧 WIP
hf-krechan Jun 1, 2021
d8b9602
➕ Add dependencies
hf-krechan Jun 1, 2021
99c608d
🙈 Add document folders to gitignore
hf-krechan Jun 1, 2021
73740fe
🎨 Rename path for documents
hf-krechan Jun 1, 2021
157ea29
🚧 Add three column tables
hf-krechan Jun 2, 2021
7e19d19
♻️ Big code refactoring part 01
hf-krechan Jun 3, 2021
feaa3ab
🚧 WIP
hf-krechan Jun 7, 2021
98d4951
🔥 remove old and unstructured code
hf-krechan Jun 7, 2021
c6b48f0
✨ Parse multi line codelists into separate dataframe rows
hf-krechan Jun 7, 2021
c80e4cf
🔥 Remove unused import of numpy
hf-krechan Jun 8, 2021
1555d73
♻ Put check row type functions into separate file
hf-krechan Jun 8, 2021
3f76626
🔥 Remove unused functions
hf-krechan Jun 8, 2021
c167240
🔧 Add black profile to isort config
hf-krechan Jun 8, 2021
fe34b3a
♻ Put write functions into separate file
hf-krechan Jun 8, 2021
07ff01d
🐛 Small bug fixes for the list row_cell_texts_as_list
hf-krechan Jun 8, 2021
1f0fd74
🎨Add additional attribute middle_cell to write SEGMENT and DATENELEMENT
hf-krechan Jun 8, 2021
2bee88f
✨ Add case for EMPTY cell
hf-krechan Jun 8, 2021
47c3abc
🎨 Add type hint for create_list_of_column_indices
hf-krechan Jun 8, 2021
969408b
🎨 Rename parser function for middle column cells
hf-krechan Jun 8, 2021
c45ca28
🔥 Remove unused lines
hf-krechan Jun 8, 2021
fcab3c8
🎨 Change start of tables list to loop through all tables
hf-krechan Jun 8, 2021
3728ff2
🔥 Remove unused line
hf-krechan Jun 8, 2021
0810ea1
🎨 Use CamelCase for enum class
hf-krechan Jun 8, 2021
bb1a7a6
🎨 Define one function for writing row into dataframe
hf-krechan Jun 8, 2021
da60cce
✨ Iterate through all paragraphs and tables
hf-krechan Jun 8, 2021
17afb54
✨ Get Prüfis from Header and tabstop positons from third row
hf-krechan Jun 8, 2021
496feb8
🎨 Create new function to read tables
hf-krechan Jun 9, 2021
145de0e
🙈 Add xlsx and csv files to gitignore
hf-krechan Jun 9, 2021
e91b1e9
🔥 Delete deprecated code
hf-krechan Jun 9, 2021
741047a
🎨 Add dynamic tabstop positions as argument
hf-krechan Jun 9, 2021
bf74129
🎨💡 Improve structure and add comments for if cases
hf-krechan Jun 9, 2021
f29a663
🎨 Remove dataframe_row argument from write_segment_name_to_dataframe
hf-krechan Jun 9, 2021
33c2ddc
🎉 First successful run through whole document \^.^/
hf-krechan Jun 9, 2021
9c518a7
🔥 Remove commented out lines
hf-krechan Jun 10, 2021
d5bd2e2
✨ Add beautify Bedingungen function
hf-krechan Jun 10, 2021
c481411
🎨 Use xlsxwriter to improve excel sheet layout
hf-krechan Jun 10, 2021
e40e038
🎨💡 Add typehint and docstring to function get_tabstop_positions
hf-krechan Jun 10, 2021
78694f0
🎨 Add typehints for return values
hf-krechan Jun 10, 2021
7860ed2
💤 Disable lines to save all prüfidentifikatoren in one xlsx file
hf-krechan Jun 10, 2021
d6e9691
🎨 Add output folder and subfolder for each export file format
hf-krechan Jun 10, 2021
4d29710
🔥 remove commented out code lines
hf-krechan Jun 10, 2021
55a7dfb
🙈 Add json files to gitignore
hf-krechan Jun 10, 2021
12ef251
🐛 Fix bug of missing multiline expression
hf-krechan Jun 10, 2021
b4ba80d
🎨 Replace hard coded left indent position with variable
hf-krechan Jun 10, 2021
6daa11a
🔥 Remove comment with depricated idea
hf-krechan Jun 10, 2021
beb4254
🎨 Improve formate of excel files
hf-krechan Jun 10, 2021
9f3159d
🩹 Remove writer.save() to avoid warning caused by double closed file
hf-krechan Jun 10, 2021
8fe9a86
🎨 Save all PID in one file
hf-krechan Jun 10, 2021
6499746
🟨 Try some different JSON structures
hf-krechan Jun 10, 2021
ccb6607
🎨 Remove table parameter in is_row_segmentname
hf-krechan Jun 11, 2021
c4e81fc
🔥 Remove template files
hf-krechan Jun 11, 2021
df29143
🎨 Remove unused table parameter in is_row_segementname
hf-krechan Jun 11, 2021
d2c7614
🎨 Replace text_in_row_as_list with edifact_struktur_cell
hf-krechan Jun 11, 2021
b1c537c
➕ Add XlsxWriter to dependencies
hf-krechan Jun 11, 2021
519db40
🎨 Remove parameter text_in_row_as_list from is_row_header call
hf-krechan Jun 11, 2021
f73eaa1
🎨 Remove text_in_row_as_list parameter from is_row_segmentname function
hf-krechan Jun 11, 2021
4fefcc8
✅ Add tests for row defintions
hf-krechan Jun 11, 2021
4f8e750
✅ Add EMTPY row type to tests
hf-krechan Jun 11, 2021
dff085b
✅🎨 Restructure test for check_row_type
hf-krechan Jun 11, 2021
3584328
🐛 Fix bugs found by unittests
hf-krechan Jun 11, 2021
0e112b5
♻ Restructure all write functions
hf-krechan Jun 11, 2021
6663870
✅ Add tests for write functions
hf-krechan Jun 11, 2021
c1e1d75
🐛 Fix issue with repeating text in the output cells
hf-krechan Jun 14, 2021
11f247f
✅ Improve test structure for better understanding
hf-krechan Jun 14, 2021
f92ac54
🎨 Comment out else case which is probably not reachable
hf-krechan Jun 14, 2021
53eec98
🎨 Remove unnecessary pass command
hf-krechan Jun 14, 2021
ceca7ee
✅ Add tests for parsing edifact struktur and bedingungen cells
hf-krechan Jun 14, 2021
6ca8f13
🐛 Fixed issue with multiline Segmentnamen got cut after first line
hf-krechan Jun 14, 2021
403f8a9
🎨 Rename TestClass and param ids
hf-krechan Jun 14, 2021
fec5fa9
✅ Add test for write_segment_name _to_dataframe
hf-krechan Jun 14, 2021
323aa70
✅🎨 Move some class variables into function to avoid conflicts
hf-krechan Jun 14, 2021
9e68370
✅ Add tests for write_segmentgruppe and write_segment
hf-krechan Jun 14, 2021
1a7a13e
✅ Add tests for write_dataelement_to_dataframe
hf-krechan Jun 14, 2021
f9a5c1f
✅🎨 Create an extra function to prepare docx table row for testing
hf-krechan Jun 15, 2021
59f21b8
🎨 Remove hard coded pruefi tabstop posistions
hf-krechan Jun 15, 2021
2c99668
✅ Add test for multi entry dataelement
hf-krechan Jun 15, 2021
9c7a4cd
📝 Add some explaining lines to the README
hf-krechan Jun 15, 2021
a8bdd6b
🚚 Add folder AHB_Extractor
hf-krechan Jun 15, 2021
1293db8
♻ Great restructuring
hf-krechan Jun 16, 2021
0be0b2c
✅ Update tests to new module structure
hf-krechan Jun 16, 2021
2e6c7e3
🐛 Fix issue with multiline dataelement in empty row
hf-krechan Jun 16, 2021
08ed5b8
🎨 Separate export functions
hf-krechan Jun 16, 2021
45ff8c5
🎨 Remove unused parameter from export_pruefidentifikator
hf-krechan Jun 16, 2021
0b5aba7
📝Add docstrings to functions in check_row_type.py
hf-krechan Jun 16, 2021
7ebf1fb
📝 Add docstrings to functions in export_functions.py
hf-krechan Jun 16, 2021
d6a96c9
📝 Add docstrings to read_functions.py
hf-krechan Jun 16, 2021
3dcc888
📝 Add docstrings to app.py
hf-krechan Jun 16, 2021
b035848
📝 Add docstrings to write_functions.py
hf-krechan Jun 16, 2021
8dc5c56
🙈 Ignore 7z files
hf-krechan Jun 16, 2021
d905692
🩹 Remove additional whitespace
hf-krechan Jun 16, 2021
a906593
🔧 Add ahb_extractor to pylint
hf-krechan Jun 16, 2021
16a6034
📝 Add module docstrings
hf-krechan Jun 16, 2021
3da9213
🚨 Disable wrong linter warnings
hf-krechan Jun 16, 2021
35670ff
🚨 Fix linter warnings
hf-krechan Jun 16, 2021
d660520
🚨🔧 Add "df" too good-names
hf-krechan Jun 16, 2021
190cf44
Fix module not found error in tests (#4)
hf-krechan Jun 17, 2021
a1e88ae
📝Add some lines for how to install and execute the ahbscraper
hf-krechan Jun 17, 2021
c4d541c
📝 Make purpose of the app clearer
hf-krechan Jun 22, 2021
d961b37
📝 Improve README
hf-krechan Jun 22, 2021
c434b6e
📝 Try to improve understanding for activating virtual environment
hf-krechan Jun 22, 2021
263b1c6
📝 Improve docstring of main function
hf-krechan Jun 22, 2021
788f111
👩‍💻 Improve user feedback in error case
hf-krechan Jun 22, 2021
fc60c83
📝 Improve some docstrings
hf-krechan Jun 22, 2021
fdfc081
📝 Add examples for RowTypes in docstring
hf-krechan Jun 22, 2021
0b207c4
💡 Add color name in comment
hf-krechan Jun 22, 2021
78f40cb
💡 Improve docstring of RowType enum
hf-krechan Jun 22, 2021
ebdb196
💡 Improve docstring of define_row_type
hf-krechan Jun 22, 2021
7600810
🔥 Remove deprecated code
hf-krechan Jun 22, 2021
a806d54
🎨 Improve function name to export *single* pruefidentifikator
hf-krechan Jun 22, 2021
a3e3e72
💡 Add comment to explain list(df.columns)[:5]
hf-krechan Jun 22, 2021
9e56a10
👩‍💻 Improve saving feedback
hf-krechan Jun 22, 2021
39e1d5a
💡 Precise error message
hf-krechan Jun 22, 2021
6f2e529
💡 Remove unnecessary text
hf-krechan Jun 22, 2021
8154b64
Install Dependabot
hf-kklein Dec 7, 2021
b55d2fb
Bump lxml from 4.6.3 to 4.6.5 (#12)
dependabot[bot] Dec 24, 2021
3da3dc0
Bump xlsxwriter from 1.4.3 to 3.0.2 (#8)
dependabot[bot] Dec 24, 2021
af8250b
Bump pandas from 1.2.4 to 1.3.5 (#11)
dependabot[bot] Dec 24, 2021
d30b252
Bump openpyxl from 3.0.7 to 3.0.9 (#10)
dependabot[bot] Dec 24, 2021
7a12783
Request Dependabot Reviews from 🐍Review Team (#15)
hf-kklein Feb 17, 2022
766d869
Bump lxml from 4.6.5 to 4.9.1 (#21)
dependabot[bot] Aug 31, 2022
f8e407f
Bump xlsxwriter from 3.0.2 to 3.0.3 (#16)
dependabot[bot] Aug 31, 2022
4789e5b
Update ahbextractor/helper/write_functions.py
hf-kklein Aug 31, 2022
f3ae77d
Update ahbextractor/helper/write_functions.py
hf-kklein Aug 31, 2022
16e7d7e
Update unittests/test_check_row_type.py
hf-kklein Aug 31, 2022
3a55f9e
Update ahbextractor/helper/write_functions.py
hf-kklein Aug 31, 2022
9255cdd
Update ahbextractor/helper/write_functions.py
hf-kklein Aug 31, 2022
66348e6
Update ahbextractor/helper/write_functions.py
hf-kklein Aug 31, 2022
52a89f2
Update ahbextractor/helper/write_functions.py
hf-kklein Aug 31, 2022
fe04463
Bump pandas from 1.3.5 to 1.4.3 (#20)
dependabot[bot] Aug 31, 2022
77318a8
Bump openpyxl from 3.0.9 to 3.0.10 (#18)
dependabot[bot] Aug 31, 2022
d316084
Bump numpy from 1.21.5 to 1.22.0 (#19)
dependabot[bot] Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,13 @@ dmypy.json

# vscode settings
.vscode/

# document folders
documents/
backup_documents/

# output files
*.xlsx
*.csv
*.json
*.7z
193 changes: 133 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,139 @@
# Python Template Repository including Tox.ini, Unittests, Linting Actions and Coverage Measurements
<!--- you need to replace the `organization/repo_name` in the status badge URLs --->
![Unittests status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Unittests/badge.svg)
![Coverage status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Coverage/badge.svg)
![Linting status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Linting/badge.svg)
![Black status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Black/badge.svg)

This is a template repository. It doesn't contain any useful code but only a minimal working setup for a Python project including:

+ a basic **project structure** with
+ tox.ini
+ requirements.in
+ and a requirements.txt derived from it
+ an example class
+ an example unit test (using pytest)
+ ready to use **Github Actions** for
+ [pytest](https://pytest.org)
+ [code coverage measurement](https://coverage.readthedocs.io) (fails below 80% by default)
+ [pylint](https://pylint.org/) (only accepts 10/10 code rating by default)
+ [black](https://github.com/psf/black) code formatter check
using [lgeiger/black-action](https://github.com/lgeiger/black-action)

By default it uses Python version 3.9.

## How to use this Repository on Your Machine

This introduction assumes that you have tox installed already (
see [installation instructions](https://tox.readthedocs.io/en/latest/install.html)) and that a `.toxbase` environment
has been created.

If this is the case, clone this repository and create the `dev` environment on your machine.
# AHB Extractor
![Unittests status badge](https://github.com/Hochfrequenz/AHBExtractor/workflows/Unittests/badge.svg)
![Coverage status badge](https://github.com/Hochfrequenz/AHBExtractor/workflows/Coverage/badge.svg)
![Linting status badge](https://github.com/Hochfrequenz/AHBExtractor/workflows/Linting/badge.svg)
![Black status badge](https://github.com/Hochfrequenz/AHBExtractor/workflows/Black/badge.svg)


This tool helps to generate machine readable files from tables inside docx documents.
hf-aschloegl marked this conversation as resolved.
Show resolved Hide resolved

## Installation
The AHB Extractor is a Python based tool. Therefor you have to make sure, that Python is running on your machine.
### Plain
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved

Create a new virtual environment
```bash
tox -e dev
python -m venv .venv
```
Activate it
#### Windows
hf-aschloegl marked this conversation as resolved.
Show resolved Hide resolved
```
.venv\Scripts\activate
```
#### MacOS/Linux
```
source .venv/bin/activate
```

### How to use with PyCharm

1. Create a new project using existing sources with your local working copy of this repository as root directory. Choose
the path `your_repo/.tox/dev/` as path of the "previously configured interpreter".
2. Set the
default [test runner of your project](https://www.jetbrains.com/help/pycharm/choosing-your-testing-framework.html) to
pytest.
3. Set
the [working directory of the unit tests](https://www.jetbrains.com/help/pycharm/creating-run-debug-configuration-for-tests.html)
to the project root (instead of the unittest directory)

### How to use with VS Code

1. Open the folder with VS Code.
2. **Select the python interpreter** which is created by tox. Open the command pallett with `CTRL + P` and type `Python: Select Interpreter`. Select the interpreter which is placed in `.tox/dev/Scripts/python.exe` under Windows or `.tox/dev/bin/python` under Linux and macOS.
3. **Setup pytest and pylint**. Therefore we open the file `.vscode/settings.json` which should be automatically generated during the interpreter setup. Insert the following lines into the settings:
```json
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"pythonTestExplorer.testFramework": "pytest",
"python.testing.pytestArgs": [
"unittests"
],
"python.linting.pylintEnabled": true
Install the requirements with
```
pip install -r requirements.txt
```
Done.
### With tox
If tox is installed system-wide, then you can just run
```
tox
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved
```
in the root directory.

## Execution

At the moment you have to define the filename of the AHB you want to extract in [`ahbextractor\ahbextractor.py`](./ahbextractor/ahbextractor.py).

If the filename is set, you can run the script with
```bash
python -m ahbextractor
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man muss auch den "documents" Ordner anlegen und dort drin die Files liegen haben oder?
Im Moment bekommt man die ja nicht durchs Repo.

You should see some output like this in your terminal
```
4. Enjoy 🤗
🔍 Extracting Pruefidentifikatoren: 11039, 11040, 11041
💥 The Excel file 11039.xlsx is open. Please close this file and try again.
💾 Saved file for Pruefidentifikator 11040
💾 Saved file for Pruefidentifikator 11041
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved
```

## PDF Dokumente
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved

The following sections give a short overview where to find the start and end for the Formate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meinst du hier mit "Formate" die Prüfi-Tabellen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dann vllt. lieber eine andere Beschreibung? Formate sind ja "UTILMD" und so oder?
Pruefidentifikatoren tables?


## APERAK (Fehlermeldung)
* Datei: `CONTRL_APERAK_AHB_2_3h_20201016.pdf`
* Start: `4.2 Tabellarische Darstellung der APERAK`
* Ende einschließlich: `4.2 Tabellarische Darstellung der APERAK`

## IFTSTA (Infomeldung)
* Dateiname: `IFTSTA_AHB_2_0b_20201016.pdf`
* Start: `4.1 Übermittlung des Status des Gesamtvorgangs im Rahmen des MSB-Wechsels 1/2`
* Ende einschließlich: `4.9 Information zur Ablehnung eines Angebots oder einer Anfrage`

## INSRPT (Prüfbericht)
* Datei: `INSRPT_AHB_1_1f_Lesefassung_20191002.pdf`
* Start: `3.1 Anwendungsfälle: Störungsmeldung, Ablehnung bzw. Bestätigung der Störungsmeldung und Ergebnisbericht`
* Ende einschließlich: `3.3 Anwendungsfälle: Informationsmeldungen des MSB in der Sparte Strom`

## INVOIC (Rechnung)
* Datei: `INVOIC_REMADV_AHB_2_4_Lesefassung_20200701.pdf`
* Start: `2.1.1 Abschlags-, NN-, WiM- und MSB-Rechnung`
* Ende einschließlich: `2.1.4 Kapazitätsrechnung`
* Start: `3.1 Anwendungsfälle REMADV`
* Ende einschließlich: `3.1 Anwendungsfälle REMADV`
## MSCONS (Messwerte und Zählerstände)
* Datei: `MSCONS_AHB_2_3c_20201001_v2.pdf`
* Start: `4.2 Anwendungsübersicht Messwert Lastgang`
* Ende einschließlich: `4.2 Anwendungsübersicht Messwert Lastgang`
* Start: `4.4 Anwendungsübersicht Messwert Energiemenge`
* Ende einschließlich: `4.4 Anwendungsübersicht Messwert Energiemenge`
* Start: `4.6 Anwendungsübersicht Messwert Zählerstand`
* Ende einschließlich: `4.6 Anwendungsübersicht Messwert Zählerstand`
* Start: `4.8 Anwendungsübersicht Messwert Storno`
* Ende einschließlich: `4.8 Anwendungsübersicht Messwert Storno`
* Start: `4.10Anwendungsübersicht Bilanzkreissummen`
* Ende einschließlich: `4.10Anwendungsübersicht Bilanzkreissummen`
* Start: `4.12Anwendungsübersicht Normiertes Profil / Profilschar / Vergangenheitsw. TEP`
* Ende eischließlich: `4.12Anwendungsübersicht Normiertes Profil / Profilschar / Vergangenheitsw. TEP`
* Start: `4.14Anwendungsübersicht EEG-Überführungszeitreihen`
* Ende einschließlich: `4.14Anwendungsübersicht EEG-Überführungszeitreihen`
* Start: `4.16Anwendungsübersicht Gasbeschaffenheitsdaten`
* Ende einschließlich: `4.16Anwendungsübersicht Gasbeschaffenheitsdaten`
* Start: `4.18Anwendungsübersicht Allokationsliste Gas / bilanzierte Menge Strom/Gas`
* Ende einschließlich: `4.18Anwendungsübersicht Allokationsliste Gas / bilanzierte Menge Strom/Gas`
* Start: `4.20Anwendungsübersicht Bewegungsdaten im Kalenderjahr vor Lieferbeginn`
* Ende einschließlich: `4.20Anwendungsübersicht Bewegungsdaten im Kalenderjahr vor Lieferbeginn`
* Start: `4.22Anwendungsübersicht Energiemenge und Leistungsmaximum`
* Ende einschließlich: `4.22Anwendungsübersicht Energiemenge und Leistungsmaximum`

## ORDERS (Bestellung)
* Datei: `REQOTE_QUOTES_ORDERS_ORDRSP_AHB_1_0c_20201001.pdf`
* Start: `3.1.1 Anfrage zur Übermittlung von Stammdaten im Initialprozess`
* Ende einschließlich: `3.5 Reklamation von Werten/Lastgängen`
* Start: `3.6.1 Anforderung eines Geräteübernahmeangebots (REQOTE)`
* Ende einschließlich: `3.10.4 Bestätigung bzw. Ablehnung der Beendigung der Rechnungsabwicklung des Messstellenbetriebs über den LF (ORDRSP`

## ORDRSP (Bestellantwort)
* Datei: `REQOTE_QUOTES_ORDERS_ORDRSP_AHB_1_0c_20201001.pdf`
* selbe Datei wie `ORDERS (Bestellung)`
* Start: ``
* Ende einschließlich: ``

## QUOTES (Angebot)
* Datei: `REQOTE_QUOTES_ORDERS_ORDRSP_AHB_1_0c_20201001.pdf`
* selbe Datei wie `ORDERS (Bestellung)`
* Start: ``
* Ende einschließlich: ``

## REQOTE (Anfrage)
* Datei: `REQOTE_QUOTES_ORDERS_ORDRSP_AHB_1_0c_20201001.pdf`
* selbe Datei wie `ORDERS (Bestellung)`
* Start: ``
* Ende einschließlich: ``
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved

## UTILMD (Stammdaten)
* Datei: `UTILMD_AHB_Stammdatenänderung_1_1b_20201016.pdf`
* Start: `8.1 Nicht bilanzierungsrelevante Änderung vom LF ohne Abhängigkeiten (jedes Stammdatum kann einzeln übermittelt werden)`
* Ende einschließlich: `9.10 Anfrage zur Stammdatenänderung von ÜNB`

## Contribute
You are very welcome to contribute to this template repository by opening a pull request against the main branch.
## UTILTS (Berechnungsformel)
* Datei: `UTILTS_AHB_Berechnungsformel_1_0b_20201016.pdf`
* Start: `4 Übermittlung der Berechnungsformel`
* Ende einschließlich: `4 Übermittlung der Berechnungsformel`
Empty file added ahbextractor/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions ahbextractor/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
This file makes the package itself executable.
You can run it with:

python -m ahbextractor

"""

from ahbextractor import ahbextractor

if __name__ == "__main__":
ahbextractor.main()
40 changes: 40 additions & 0 deletions ahbextractor/ahbextractor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Main script of the AHB Extractor
"""

from pathlib import Path

import docx

from ahbextractor.helper.read_functions import get_ahb_extract


def main():
"""
Main function of the module ahbextractor.
It reads the docx file and calls the function to extract all infos.
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved
"""

input_directory_path = Path.cwd() / "documents"
ahb_file_name = "UTILMD_AHB_WiM_3_1c_2021_04_01_2021_03_30.docx"
path_to_ahb_file = input_directory_path / ahb_file_name

output_directory_path = Path.cwd() / "output"
path_to_all_in_one_excel = output_directory_path / "xlsx" / f"{ahb_file_name[:-5]}.xlsx"

# Remove old "all in one excel file" if it already exists
if path_to_all_in_one_excel.exists():
path_to_all_in_one_excel.unlink(missing_ok=False)

try:
doc = docx.Document(path_to_ahb_file) # Creating word reader object.

except IOError:
print("There was an error opening the file!")
hf-krechan marked this conversation as resolved.
Show resolved Hide resolved
return

get_ahb_extract(document=doc, output_directory_path=output_directory_path, ahb_file_name=ahb_file_name)


if __name__ == "__main__":
main()
Empty file added ahbextractor/helper/__init__.py
Empty file.
Loading