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
84 stars 17 forks source link

CSV export fails: `KeyError: 'additional_table'` #414

Closed nesnoj closed 1 year ago

nesnoj commented 1 year ago

Today I installed from scratch (after #412 !) using develop (head: 95e32a0451db1073e440ae88a35eeba0336ce2c4). I did not delete the ~/.open-MaStR/ dir but the open-mastr.db file before downloading. Then I tried to export to CSV which fails - see below. Is this related to #401 ?

>>> db.to_csv(None)
2023-01-20 14:02:11,615 [INFO] Starting csv-export
2023-01-20 14:02:11,619 [INFO] Technology tables: ['wind', 'solar', 'biomass', 'hydro', 'gsgk', 'combustion', 'nuclear', 'storage']
2023-01-20 14:02:11,619 [INFO] Additional tables: ['gas_consumer', 'gas_producer', 'gas_storage', 'gas_storage_extended', 'electricity_consumer', 'locations_extended', 'market_actors', 'market_roles', 'grid_connections', 'grids', 'balancing_area', 'permit', 'deleted_units']
2023-01-20 14:02:11,619 [INFO] Tables are saved to: /home/lucky_luke/.open-MaStR/data/dataversion-2023-01-20
Performing reverse fill of basic units: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:38<00:00,  4.80s/it]
2023-01-20 14:02:59,610 [INFO] Created csv: ['bnetza_mastr_wind_raw.csv'] 
2023-01-20 14:04:17,845 [INFO] Created csv: ['bnetza_mastr_solar_raw.csv'] 
2023-01-20 14:06:28,551 [INFO] Appended 500000 rows to: ['bnetza_mastr_solar_raw.csv']
2023-01-20 14:08:05,980 [INFO] Appended 500000 rows to: ['bnetza_mastr_solar_raw.csv']
2023-01-20 14:09:24,282 [INFO] Appended 500000 rows to: ['bnetza_mastr_solar_raw.csv']
2023-01-20 14:10:43,776 [INFO] Appended 500000 rows to: ['bnetza_mastr_solar_raw.csv']
2023-01-20 14:11:14,780 [INFO] Appended 201829 rows to: ['bnetza_mastr_solar_raw.csv']
2023-01-20 14:11:21,514 [INFO] Created csv: ['bnetza_mastr_biomass_raw.csv'] 
2023-01-20 14:11:22,851 [INFO] Created csv: ['bnetza_mastr_hydro_raw.csv'] 
2023-01-20 14:11:23,277 [INFO] Created csv: ['bnetza_mastr_gsgk_raw.csv'] 
2023-01-20 14:11:32,629 [INFO] Created csv: ['bnetza_mastr_combustion_raw.csv'] 
2023-01-20 14:11:33,185 [INFO] Created csv: ['bnetza_mastr_nuclear_raw.csv'] 
2023-01-20 14:12:40,315 [INFO] Created csv: ['bnetza_mastr_storage_raw.csv'] 
2023-01-20 14:12:49,301 [INFO] Appended 65707 rows to: ['bnetza_mastr_storage_raw.csv']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lucky_luke/bnetza_mastr/bnetza_open_mastr_2023-01-20/open-MaStR/open_mastr/mastr.py", line 357, in to_csv
    db_query_to_csv(db_query=create_db_query
  File "/home/lucky_luke/bnetza_mastr/bnetza_open_mastr_2023-01-20/open-MaStR/open_mastr/utils/helpers.py", line 713, in db_query_to_csv
    csv_file = os.path.join(data_path, filenames["raw"]["additional_table"][data_table])
KeyError: 'additional_table'

I thought it might be caused by None in db.to_csv(None) but as is prints the list of technology and additional tables, that's unlikely, is it?

chrwm commented 1 year ago

Hi @nesnoj, this is related to https://github.com/OpenEnergyPlatform/open-MaStR/pull/401#discussion_r1067989605 and https://github.com/OpenEnergyPlatform/open-MaStR/issues/410

Just delete your "filenames.yml" and try to export again. It should work then. I'll fix #410 asap.

nesnoj commented 1 year ago

Hi @nesnoj, this is related to #401 (comment) and #410

Just delete your "filenames.yml" and try to export again. It should work then. I'll fix #410 asap.

Thanks @chrwm, I'll give it a try.

chrwm commented 1 year ago

Can this be closed?

nesnoj commented 1 year ago

Yepp, thx for tracking