Basic functions
open_mastr.Mastr
Mastr
is used to download the MaStR database and keep it up-to-date.
A SQL database is used to mirror the MaStR database. It can be filled with data either from the MaStR-bulk download or from the MaStR-API.
PARAMETER | DESCRIPTION |
---|---|
engine |
Defines the engine of the database where the MaStR is mirrored to. Default is 'sqlite'.
TYPE:
|
connect_to_translated_db |
DEFAULT:
|
download(method='bulk', data=None, date=None, bulk_cleansing=True, api_processes=None, api_limit=50, api_chunksize=1000, api_data_types=None, api_location_types=None, **kwargs)
Download the MaStR either via the bulk download or via the MaStR API and write it to a SQLite database.
PARAMETER | DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
method |
Either "API" or "bulk". Determines whether the data is downloaded via the
zipped bulk download or via the MaStR API. The latter requires an account
from marktstammdatenregister.de,
(see :ref:
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
data |
Determines which types of data are written to the database. If None, all data is used. If it is a list, possible entries are listed below with respect to the download method. Missing categories are being developed. If only one data is of interest, this can be given as a string. Default to None, where all data is included.
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
date |
Default to
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
bulk_cleansing |
If True, data cleansing is applied after the download (which is recommended). Default to True.
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_processes |
Number of parallel processes used to download additional data.
Defaults to Warning The implementation of parallel processes is currently under construction.
Please let the argument
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_limit |
Limit the number of units that data is downloaded for. Defaults to
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_chunksize |
Data is downloaded and inserted into the database in chunks of
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_data_types |
Select the type of additional data that should be retrieved. Choose from "unit_data", "eeg_data", "kwk_data", "permit_data". Defaults to all.
TYPE:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_location_types |
Select the type of location that should be retrieved. Choose from "location_elec_generation", "location_elec_consumption", "location_gas_generation", "location_gas_consumption". Defaults to all.
TYPE:
|
to_csv(tables=None, chunksize=500000, limit=None)
Save the database as csv files along with the metadata file. If 'tables=None' all possible tables will be exported.
PARAMETER | DESCRIPTION |
---|---|
tables |
For exporting selected tables choose from: ["wind", "solar", "biomass", "hydro", "gsgk", "combustion", "nuclear", "storage", "balancing_area", "electricity_consumer", "gas_consumer", "gas_producer", "gas_storage", "gas_storage_extended", "grid_connections", "grids", "market_actors", "market_roles", "locations_extended, 'permit', 'deleted_units' ]
TYPE:
|
chunksize |
Defines the chunksize of the tables export. Default value is 500.000 rows to include in each chunk.
TYPE:
|
limit |
Limits the number of exported data rows.
TYPE:
|
translate()
A database can be translated only once.
Deletes translated versions of the currently connected database.
Translates currently connected database,renames it with '-translated' suffix and updates self.engine's path accordingly.