Automatic downloading of MRIO databases

Pymrio includes functions to automatically download some of the publicly available global EE MRIO databases. This is currently implemented for EXIOBASE 3, OECD and WIOD.

The functions described here download the raw data files. Thus, they can also be used for post processing by other tools.

EXIOBASE 3 download

EXIOBASE 3 is licensed under the Creative Commons Attribution ShareAlike 4.0 International-license. Thus you can use EXIOBASE 3 for analyses as well as remix, tweak, and build uponit, even commercially, as long as you give credit to the EXIOBASE compilers and share your results/new databases under the same licence. The suggested citation for EXIOBASE 3 is Stadler et al 2018. You can find more information, links to documentation as well as concordance matrices on the EXIOBASE 3 Zenodo repository. The download function of pymrio also downloads the files from this repository.

To download, start with:

[1]:
import pymrio

and define a folder for storing the data:

[2]:
exio3_folder = "/tmp/mrios/autodownload/EXIO3"

With that we can start the download with (this might take a moment):

[3]:
exio_downloadlog = pymrio.download_exiobase3(
    storage_folder=exio3_folder, system="pxp", years=[2011, 2012]
)

The command above will download the latest EXIOBASE 3 tables in the product by product classification (system=’pxp’) for the years 2011 and 2012. Both parameters (system and years) are optional and when omitted the function will download all available files.

The function returns a log of the download data (which is stored in download_log.json in the download folder). You can inspect the meta data by:

[4]:
print(exio_downloadlog)
Description: Download log of EXIOBASE3
MRIO Name: EXIO3
System: pxp
Version: 10.5281/zenodo.3583070
File: /tmp/mrios/autodownload/EXIO3/download_log.json
History:
20230323 09:32:39 - FILEIO -  Downloaded https://zenodo.org/record/5589597/files/IOT_2012_pxp.zip to IOT_2012_pxp.zip
20230323 09:26:03 - FILEIO -  Downloaded https://zenodo.org/record/5589597/files/IOT_2011_pxp.zip to IOT_2011_pxp.zip
20230323 09:19:45 - NOTE -  Download log created
20230323 09:19:45 - NOTE -  python_version: 3.9.16
20230323 09:19:45 - NOTE -  pymrio_version: 0.5.0dev
20230323 09:19:45 - NOTE -  os: Linux
20230323 09:19:45 - NOTE -  hostname: NTNU09417
20230323 09:19:45 - NOTE -  username: konstans

By default, the download_exiobase3 fetches the latest version of EXIOBASE3 available at the EXIOBASE 3 Zenodo repository. To download one of the previous versions specify the DOI with the doi parameter:

[5]:
prev_version_storage = "/tmp/mrios/autodownload/EXIO3_7"
exio_downlog_37 = pymrio.download_exiobase3(
    storage_folder=prev_version_storage,
    system="ixi",
    years=2004,
    doi="10.5281/zenodo.3583071",
)
[6]:
print(exio_downlog_37)
Description: Download log of EXIOBASE3
MRIO Name: EXIO3
System: ixi
Version: 10.5281/zenodo.3583071
File: /tmp/mrios/autodownload/EXIO3_7/download_log.json
History:
20230323 09:44:54 - FILEIO -  Downloaded https://zenodo.org/record/3583071/files/IOT_2004_ixi.zip to IOT_2004_ixi.zip
20230323 09:43:49 - NOTE -  Download log created
20230323 09:43:49 - NOTE -  python_version: 3.9.16
20230323 09:43:49 - NOTE -  pymrio_version: 0.5.0dev
20230323 09:43:49 - NOTE -  os: Linux
20230323 09:43:49 - NOTE -  hostname: NTNU09417
20230323 09:43:49 - NOTE -  username: konstans

We also recommend to specifiy a specific DOI version even when using the latest version of EXIOBASE. In that way the used version is documented in the code and can be reproduced in case a newer EXIOBASE version becomes available.

WIOD download

DUE TO A RESTRUCTERING OF THE WIOD WEBPAGE THIS IS CURRENTLY BROKEN.

WIOD is licensed under the Creative Commons Attribution 4.0 International-license. Thus you can remix, tweak, and build upon WIOD, even commercially, as long as you give credit to WIOD. The WIOD web-page suggest to cite Timmer et al. 2015 when you use the database. You can find more information on the WIOD webpage.

The download function for WIOD currently processes the 2013 release version of WIOD.

To download, start with:

[7]:
import pymrio

Define a folder for storing the data

[8]:
wiod_folder = "/tmp/mrios/autodownload/WIOD2013"

And start the download with (this will take a couple of minutes):

[9]:
wiod_meta = pymrio.download_wiod2013(storage_folder=wiod_folder)

The function returns the meta data for the release (which is stored in metadata.json in the download folder). You can inspect the meta data by:

[10]:
print(wiod_meta)
Description: WIOD metadata file for pymrio
MRIO Name: WIOD
System: IxI
Version: data13
File: /tmp/mrios/autodownload/WIOD2013/metadata.json
History:
20210223 15:46:26 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/water/wat_may12.zip to wat_may12.zip
20210223 15:46:25 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/materials/mat_may12.zip to mat_may12.zip
20210223 15:46:25 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/land/lan_may12.zip to lan_may12.zip
20210223 15:46:24 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/AIR/AIR_may12.zip to AIR_may12.zip
20210223 15:46:24 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/CO2/CO2_may12.zip to CO2_may12.zip
20210223 15:46:23 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/EM/EM_may12.zip to EM_may12.zip
20210223 15:46:22 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/EU/EU_may12.zip to EU_may12.zip
20210223 15:46:21 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/SEA/WIOD_SEA_July14.xlsx to WIOD_SEA_July14.xlsx
20210223 15:46:20 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/update_sep12/wiot/wiot09_row_sep12.xlsx to wiot09_row_sep12.xlsx
20210223 15:46:15 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot04_row_apr12.xlsx to wiot04_row_apr12.xlsx
 ... (more lines in history)

The WIOD database provide data for several years and satellite accounts. In the default case, all of them are downloaded. You can, however, specify years and satellite account.

You can specify the years as either int or string (2 or 4 digits):

[11]:
res_years = [97, 2004, "2005"]

The available satellite accounts for WIOD are listed in the WIOD_CONFIG. To get them import this dict by:

[12]:
from pymrio.tools.iodownloader import WIOD_CONFIG
[13]:
WIOD_CONFIG
[13]:
{'url_db_view': 'http://www.wiod.org/database/wiots13',
 'url_db_content': 'http://www.wiod.org/',
 'mrio_regex': 'protected.*?wiot\\d\\d.*?xlsx',
 'satellite_urls': ['http://www.wiod.org/protected3/data13/SEA/WIOD_SEA_July14.xlsx',
  'http://www.wiod.org/protected3/data13/EU/EU_may12.zip',
  'http://www.wiod.org/protected3/data13/EM/EM_may12.zip',
  'http://www.wiod.org/protected3/data13/CO2/CO2_may12.zip',
  'http://www.wiod.org/protected3/data13/AIR/AIR_may12.zip',
  'http://www.wiod.org/protected3/data13/land/lan_may12.zip',
  'http://www.wiod.org/protected3/data13/materials/mat_may12.zip',
  'http://www.wiod.org/protected3/data13/water/wat_may12.zip']}

To restrict this list, you can either copy paste the urls or automatically select the accounts:

[14]:
sat_accounts = ["EU", "CO2"]
res_satellite = [
    sat
    for sat in WIOD_CONFIG["satellite_urls"]
    if any(acc in sat for acc in sat_accounts)
]
[15]:
res_satellite
[15]:
['http://www.wiod.org/protected3/data13/EU/EU_may12.zip',
 'http://www.wiod.org/protected3/data13/CO2/CO2_may12.zip']
[16]:
wiod_meta_res = pymrio.download_wiod2013(
    storage_folder="/tmp/foo_folder/WIOD2013_res",
    years=res_years,
    satellite_urls=res_satellite,
)
[17]:
print(wiod_meta_res)
Description: WIOD metadata file for pymrio
MRIO Name: WIOD
System: IxI
Version: data13
File: /tmp/foo_folder/WIOD2013_res/metadata.json
History:
20210218 15:29:34 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot01_row_apr12.xlsx to wiot01_row_apr12.xlsx
20210218 15:29:33 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot00_row_apr12.xlsx to wiot00_row_apr12.xlsx
20210218 15:29:32 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/CO2/CO2_may12.zip to CO2_may12.zip
20210218 15:29:31 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/EU/EU_may12.zip to EU_may12.zip
20210218 15:29:30 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot04_row_apr12.xlsx to wiot04_row_apr12.xlsx
20210218 15:29:27 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot97_row_apr12.xlsx to wiot97_row_apr12.xlsx
20210218 15:29:26 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot05_row_apr12.xlsx to wiot05_row_apr12.xlsx

Subsequent download will only catch files currently not present in the folder, e.g.:

[18]:
additional_years = [2000, 2001]
wiod_meta_res = pymrio.download_wiod2013(
    storage_folder="/tmp/foo_folder/WIOD2013_res",
    years=res_years + additional_years,
    satellite_urls=res_satellite,
)

only downloads the years given in additional_years, appending these downloads to the meta data file.

[19]:
print(wiod_meta_res)
Description: WIOD metadata file for pymrio
MRIO Name: WIOD
System: IxI
Version: data13
File: /tmp/foo_folder/WIOD2013_res/metadata.json
History:
20210218 15:29:34 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot01_row_apr12.xlsx to wiot01_row_apr12.xlsx
20210218 15:29:33 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot00_row_apr12.xlsx to wiot00_row_apr12.xlsx
20210218 15:29:32 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/CO2/CO2_may12.zip to CO2_may12.zip
20210218 15:29:31 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/EU/EU_may12.zip to EU_may12.zip
20210218 15:29:30 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot04_row_apr12.xlsx to wiot04_row_apr12.xlsx
20210218 15:29:27 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot97_row_apr12.xlsx to wiot97_row_apr12.xlsx
20210218 15:29:26 - FILEIO -  Downloaded http://www.wiod.org/protected3/data13/wiot_analytic/wiot05_row_apr12.xlsx to wiot05_row_apr12.xlsx

To catch all files, irrespective if present in the storage_folder or not pass overwrite_existing=True

OECD download

The OECD Inter-Country Input-Output tables (ICIO) are available on the OECD webpage. There is no specific license given for the these tables, but the webpage state that “Data can be downloaded for free” (per June 2023) and to cite this database “OECD (2021), OECD Inter-Country Input-Output Database, http://oe.cd/icio”.

Currently OECD provides three versions 2016, 2018, and 2021, which are available through pymrio

To download the data, we first define the folder for storing the data (these will be created if they do not exist yet):

[20]:
oecd_folder_v2021 = "/tmp/mrios/autodownload/OECD_2021"
oecd_folder_v2018 = "/tmp/mrios/autodownload/OECD_2018"

Than we can start the download with

[21]:
log_2021 = pymrio.download_oecd(storage_folder=oecd_folder_v2021)

By default, the 2021 release of the OECD - ICIO tables are downloaded. To retrieve other versions, simply pass “version=’v<version date>’”, for example to get the 2018 release, pass “version=’v2018’” .

As for WIOD, specific years can be specified by passing a list of years:

[22]:
log_2018 = pymrio.download_oecd(
    storage_folder=oecd_folder_v2018, version="v2016", years=[2003, 2008]
)

However, the 2021 release of OECD is only available in 5-year bundles starting from 1995 to 2018 1995-1999, 2000-2004, 2005-2009, 2010-2014, 2015-2018

Therefore whenever 2021 release is used, it is recommended to pass years as a list of the wanted bundles in string forms:

[ ]:
log_2021 = pymrio.download_oecd(
    storage_folder=oecd_folder_v2021, years=["1995-1999", "2015-2018"]
)

Otherwise the corresponding bundles for the entered years would be downloaded, for example if year 2003 is requested, the bundle 2000-2004 would be downloaded

[ ]:
log_2021 = pymrio.download_oecd(storage_folder=oecd_folder_v2021, years=[2003, 2012])

The bundles 2000-2004 and 2010-2014 would be downloaded

The function returns a log for the download progress and MRIO info:

[23]:
print(log_2021)
Description: OECD-ICIO download
MRIO Name: OECD-ICIO
System: IxI
Version: v2021
File: \tmp\mrios\autodownload\OECD_2021\download_log.json
History:
20230706 15:35:10 - FILEIO -  Downloaded https://stats.oecd.org/wbos/fileview2.aspx?IDFile=2c2f499f-5703-4034-9457-2f7518e8f2fc to ICIO2021_2010-2014.zip
20230706 15:31:47 - FILEIO -  Downloaded https://stats.oecd.org/wbos/fileview2.aspx?IDFile=8adf89dd-18b4-40fe-bc7f-c822052eb961 to ICIO2021_2000-2004.zip
20230706 15:29:43 - NOTE -  Download log created
20230706 15:29:43 - NOTE -  python_version: 3.11.2
20230706 15:29:43 - NOTE -  pymrio_version: 0.5.1
20230706 15:29:43 - NOTE -  os: Windows
20230706 15:29:43 - NOTE -  hostname: NTNU09702
20230706 15:29:43 - NOTE -  username: hazimh

Eora26 download

Eora26 provides a simplified, symmetric version of the full Eora database.

Downloading the Eora data requires registration through the Eora website (worldmrio) . Currently (August 2023), open Eora26 data are only offered for the years 1990 - 2016.

Therefore, you have to have the Eora account email and password in advance to use the downloader.

Setup the download with

[14]:
import pymrio

eora_folder = "/tmp/mrios/eora26"

Start the download with (passing the email and password of the eora account) If you pass invalid email or password, you get a prompt about that and asked to enter them again, otherwise the function will download the data (this can take some minutes)

This will download all available years 1990 - 2016

[ ]:
eora_log = pymrio.download_eora26(
    storage_folder=eora_folder,
    email="<Your Eora account email>",
    password="<Your Eora account password>",
)
Eora account with this email was not found

            Please try again or register a new user at the following website:

            https://worldmrio.com/login.jsp
The password for this email account is incorrect

            Please try again
[16]:
print(eora_log)
Description: Eora metadata file for pymrio
MRIO Name: Eora
System: ixi
Version: v199.82
File: /tmp/mrios/eora26/metadata.json
History:
20180111 10:26:35 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_1995_bp.zip to Eora26_1995_bp.zip
20180111 10:26:26 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_1996_bp.zip to Eora26_1996_bp.zip
20180111 10:26:17 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_1997_bp.zip to Eora26_1997_bp.zip
20180111 10:25:57 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_1998_bp.zip to Eora26_1998_bp.zip
20180111 10:25:47 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_1999_bp.zip to Eora26_1999_bp.zip
20180111 10:25:37 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_2000_bp.zip to Eora26_2000_bp.zip
20180111 10:25:21 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_2001_bp.zip to Eora26_2001_bp.zip
20180111 10:25:08 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_2002_bp.zip to Eora26_2002_bp.zip
20180111 10:24:58 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_2003_bp.zip to Eora26_2003_bp.zip
20180111 10:24:46 - FILEIO -  Downloaded http://worldmrio.com/ComputationsM/Phase199/Loop082/simplified/Eora26_2004_bp.zip to Eora26_2004_bp.zip
 ... (more lines in history)

As in the case of the WIOD downloader, you can restrict the

  1. years to download by passing years=[list of int or str - 4 digits]

  2. force the overwriting of existing files by passing overwrite_existing=True

Satellite accounts, however, can not be restricted since they are included in one file.

The tables are in basic prices as it is the only price system available to download for Eora26.

EXIOBASE download (previous version 1 and 2)

Previous EXIOBASE version requires registration prior to download and therefore an automatic download has not been implemented. For further information check the download instruction at the EXIOBASE example notebook.

GLORIA download

The Global Resource Input Output Assessment (GLORIA) database are available to download through a dropbox folder GLORIA database. There is no specific licence given for the this database.

Currently (as per April 2023), there are four available versions 53, 54, 55, and 57 (Release 056 was only distributed to a limited number of users for feedback).

The download function can (as per April 2023) download all four versions

To download, start with:

[ ]:
import pymrio

Define a folder for storing the data

[ ]:
gloria_folder = "/tmp/mrios/autodownload/GLORIA2014"

And start the download with (this will take a couple of minutes):

[ ]:
gloria_log_2014 = pymrio.download_gloria(storage_folder=gloria_folder)

The function returns the download log data for the release (which is stored in download_log.json in the download folder). You can inspect the log data by:

[ ]:
print(gloria_log_2014)
Description: Download log of Gloria
MRIO Name: GLORIA
System: IxI
Version: 57
File: /tmp/mrios/autodownload/GLORIA2014/download_log.json
History:
20230418 07:51:15 - NOTE -  Download log created
20230418 07:51:15 - NOTE -  python_version: 3.11.3
20230418 07:51:15 - NOTE -  pymrio_version: 0.5.0dev
20230418 07:51:15 - NOTE -  os: Linux
20230418 07:51:15 - NOTE -  hostname: instance-exio-svr
20230418 07:51:15 - NOTE -  username: hazimh
20230418 07:50:38 - FILEIO -  Downloaded https://dl.dropboxusercontent.com/sh/o4fxq94n7grvdbk/AACposoILlF8OETb20yh4st7a/latest_release/057/GLORIA_MRIO_Loop057_part_I_MRIOdatabase/GLORIA_MRIOs_57_2014.zip?dl=0 to GLORIA_MRIOs_57_2014.zip
20230418 07:46:30 - NOTE -  Download log created
20230418 07:46:30 - NOTE -  python_version: 3.11.3
20230418 07:46:30 - NOTE -  pymrio_version: 0.5.0dev
 ... (more lines in history)

By default the function downloads all years for the final release (57 as per April 2023), but the year and version can be specified by passing them to the function

[ ]:
gloria_log_v053_2012 = pymrio.download_gloria(gloria_folder, year=2012, version=53)