OpenEnergyPlatform / open-MaStR

A collaborative software to download the energy database Marktstammdatenregister (MaStR)
https://open-mastr.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
88 stars 19 forks source link

Key Error 'einheitenaenderungnetzbetreiberzuordnungen' #569

Closed AhmadShelbayeh closed 1 month ago

AhmadShelbayeh commented 1 month ago

Description of the issue

Hey guys, I am getting a key error when downloading the Bulk data. Code: from open_mastr import Mastr db = Mastr() today_date = datetime.now().strftime('today') db.download(method='bulk', data=["wind", "market", "permit", "deleted_units"], date=today_date)

KeyError: 'einheitenaenderungnetzbetreiberzuordnungen'

Steps to Reproduce

Ideas of solution

Context and Environment

Version used: 0.14.3. and 0.14.4. Environment setup and (python) version: 3.11. & 3.12.

FlorianK13 commented 1 month ago

Hi @AhmadShelbayeh Based on this code line I assume that we have fixed this already. However a usual problem is that new versions of the database scheme are not initialized if an old database still exists. One solution should be that you delete your sqlite database (or the whole~/.open-mastr folder) and rerun your code.

If this does not work, you can answer again in this issue.

AhmadShelbayeh commented 1 month ago

@FlorianK13 Unfortunately, I deleted the entire folder and reran the code, but I am still encountering the same error. It seems the issue was not resolved by deleting the folder. Could you please help me troubleshoot this problem?

AhmadShelbayeh commented 1 month ago

@FlorianK13

This is the error:

Download has started, this can take several minutes.The download bar is only a rough estimate. C:\Users\ahmad.shelbayeh.open-MaStR\data\xml_download\Gesamtdatenexport_20240930.zip: 19149 [09:20, 34.19/s]
Download is finished. It took 560 seconds. MaStR was successfully downloaded to C:\Users\ahmad.shelbayeh.open-MaStR\data\xml_download. Table 'wind_eeg' is filled with data 'anlageneegwind' from the bulk download. File 'AnlagenEegWind.xml' is parsed. Data is cleansed. Traceback (most recent call last):

Cell In[1], line 13 db.download(method='bulk', data=[

File D:\Prog.cpy\Data\Anaconda3\envs\Ahmad\lib\site-packages\open_mastr\mastr.py:231 in download write_mastr_xml_to_database(

File D:\Prog.cpy\Data\Anaconda3\envs\Ahmad\lib\site-packages\open_mastr\xml_download\utils_write_to_database.py:34 in write_mastr_xml_to_database if is_table_relevant(

File D:\Prog.cpy\Data\Anaconda3\envs\Ahmad\lib\site-packages\open_mastr\xml_download\utils_write_to_database.py:76 in is_table_relevant tablename_mapping[xml_tablename]["class"] is not None

KeyError: 'einheitenaenderungnetzbetreiberzuordnungen'

FlorianK13 commented 1 month ago

And your version right now is 0.14.4? Because 0.14.3 would initialize the old database schema.

AhmadShelbayeh commented 1 month ago

@FlorianK13 How can I know my version, is it by run pip install --upgrade open-mastr, if yes my version is: open-mastr in d:\prog.cpy\data\anaconda3\envs\ahmad\lib\site-packages (0.14.1) how can solve it?

FlorianK13 commented 1 month ago

Then you need to run pip install --upgrade open-mastr

AhmadShelbayeh commented 1 month ago

@FlorianK13 it works, thanks