Basic functions
open_mastr.Mastr
Mastr is used to download the MaStR database and keep it up-to-date.
An SQL database is used to mirror the MaStR database. It is filled by downloading and parsing the MaStR via bulk download.
| PARAMETER | DESCRIPTION |
|---|---|
engine
|
Defines the engine of the database where the MaStR is mirrored to. Default is 'sqlite'.
TYPE:
|
connect_to_translated_db
|
DEFAULT:
|
browse_available_downloads()
Browse available MaStR downloads from the website without starting the download.
This method fetches and displays all available download dates from the MaStR website, allowing users to see what historical data is available before deciding to download.
| RETURNS | DESCRIPTION |
|---|---|
list of dict
|
List of available downloads with date, version, and type information. |
Examples:
download(method='bulk', data=None, date=None, bulk_cleansing=True, keep_old_downloads=False, select_date_interactively=False, **kwargs)
Downloads the MaStR registry and writes it to a local database.
| PARAMETER | DESCRIPTION | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
method
|
Only "bulk" is a valid value. The download via the MaStR SOAP API has been removed. Defaults to 'bulk'.
TYPE:
|
||||||||||
data
|
Specifies which tables to download. Possible values:
Usage:
TYPE:
|
||||||||||
date
|
Default to
TYPE:
|
||||||||||
select_date_interactively
|
If set to True, the user will be presented with a list of available download dates
from the MaStR website and can interactively select which date to download.
This allows downloading historical data instead of just the latest available data.
When True, the
TYPE:
|
||||||||||
bulk_cleansing
|
If set to True, data cleansing is applied after the download (which is recommended).
In its original format, many entries in the MaStR are encoded with IDs. Columns like
TYPE:
|
||||||||||
keep_old_downloads
|
If set to True, prior downloaded MaStR zip files will be kept.
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_actors_and_roles", "locations_extended", "permit", "deleted_units", "storage_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.