Creating an Empty Database, from tabular information¶
This example shows how you can create a data template from tabular info, (namely the list of regions, sectors, …).
from mario import DataTemplate
At first you need to identify what kind of table you want to buid. Lets go with a IOT table
template = DataTemplate("IOT")
Now you can create a template file where you can fill your information
template.get_template_excel("iot_template.xlsx")
The template looks like:
Alt text¶
Now you can fill the data,
Lets assume you want to build a table with:
Regions: - Italy
Sectors: - Primary - Secondary
Consumption Categories: - Final Demand
Factors of production: - Labor
Satellite accounts: - CO2
The filled template should look like:
Alt text¶
Let’s call the new filled excel file as iot_template_filled.xlsx.
Now we can read back the file!
template.read_template("iot_template_filled.xlsx")
Now you can transfrom the template into a mario.Database, that can be later filled using other mario functionalities. Or you can save the template database into an excel file, which follows the mario excel parser standards!
database = template.to_Database()
database
name = unknow
table = IOT
scenarios = ['baseline']
Factor of production = 1
Satellite account = 1
Consumption category = 1
Region = 1
Sector = 2
database.X
Item | production | ||
---|---|---|---|
Region | Level | Item | |
Italy | Sector | Primary | 0 |
Secondary | 0 |
database.to_excel("new_data.xlsx")
Link to the jupyter notebook file
.