For supported inputs and a short import recipe, see the BONSAI guide. This downloadable example follows both formats.

This notebook shows how to parse BONSAI’s Balanced hybrid supply-use table (HSUT) and native b2 hybrid input-output table (HIOT). Monetary SUT exports are not supported. The checked source directory is 20260615, with reference year 2016. Its name does not identify an immutable snapshot: individual files can be updated within it.

What this notebook covers#

  • which local files the parser expects;

  • how to read a Balanced HSUT or native b2 HIOT;

  • how to inspect regional classifications and native units;

  • where to find import diagnostics and further analysis methods.

Jump to Balanced HSUT or native b2 HIOT.

Relevant source pages#

Obtain the bundle from the project’s shared data storage, under _b Next version/Balanced (HSUT) or _b Next version/HIOT (HIOT). MARIO does not download BONSAI automatically.

Main entry point#

Use mario.parse_bonsai(...) with the original ZIP or its extracted directory. The default table="SUT" reads the Balanced HSUT; table="IOT" reads the native b2 HIOT demonstrated below.

Key arguments and local layout#

  • path: a ZIP or extracted directory for the requested table;

  • table: "SUT" (default) for the Balanced HSUT or "IOT" for the native b2 HIOT;

  • extensions: True (default) includes the recalculated elementary flows; False reads only the economic tables.

For the Balanced HSUT, the parser reads these files:

20260615/
├── classification.csv
├── hybrid_supply_w_characteristic_unit.csv
├── hybrid_use_w_characteristic_unit.csv
└── all_elementary_flows_AB_and_BB.csv

The last file is needed only when extensions=True. Other files in the bundle can be left in place. See mario.parse_bonsai for all arguments.

[ ]:
import mario

mario.set_log_verbosity("warning")

Parse the HSUT#

Pass the ZIP directly; no manual extraction is needed. You can also pass the extracted 20260615 directory.

Inspect the parsed database#

The result is a MARIO SUT database. Check its regions and the native commodity units before starting an analysis.

[ ]:
db.get_index("Region")
[ ]:
db.units["Commodity"].head()

Parse the native b2 HIOT#

Use table="IOT" with the extracted HIOT/20260615 directory or a ZIP containing one release. The parser imports the final Stone/iLUC/capital model directly.

20260615/
├── extended_size_hiot.b2.pkl
├── final_demand.b2.csv
└── total_elementary_flow_w_iLUC.csv

The elementary-flow file is needed only when extensions=True. Only use a trusted BONSAI pickle export.

The reference year is inferred from elementary-flow time values; pass year=2016 if those values are unavailable. Original product codes, native units and region-specific Sector lists are retained. Inspect a single region with get_index("Sector", region=...); the activity-to-reference-product mapping is in db_iot.info["bonsai"]["reference_products"].

[ ]:
from pathlib import Path
import mario

hiot_path = Path("/path/to/HIOT/20260615")
db_iot = mario.parse_bonsai(path=hiot_path, table="IOT")

sectors_it = db_iot.get_index("Sector", region="IT")
print(f"Reference year: {db_iot.meta.year}")
print(f"Native production nodes: {db_iot.X.shape[0]:,}")
print(f"Sectors in Italy: {len(sectors_it)}")
print("First Italian sectors:", sectors_it[:8])

Notes#

  • Activity, commodity and Sector classifications can differ between regions. See regional classifications and Basic inspections for the index API.

  • Value-added accounts are not available in these inputs; MARIO uses zero placeholders.

  • Satellite labels use name | compartment; IDs disambiguate homonyms. Units and native identities remain in db.units["Satellite account"] and db.info["bonsai"]["satellites"] (or the corresponding db_iot attributes).

  • Import diagnostics are available in db.info["bonsai"]. Unmatched elementary-flow rows generate a warning by default; use unmatched_extensions="raise" to reject them. For the HIOT, unmatched_final_demand controls the analogous final-demand policy.

  • The HIOT preserves the native net-supply model through X = diag(T) and Z = diag(X) - T, including substitution credits. See the parser API for representation and coverage details.

  • Keep the default calc_all=False when loading a full database. Request only the matrices needed for your analysis; full inverse matrices can require substantial memory.

  • For subsequent calculations, see the matrices API and GHG characterization. Per-unit satellite multipliers are exposed as fc for HSUT commodities and f for HIOT sectors, in the native product units.