Export a database
Save model tables and current sets for inspection or a later MARIO session.
Choose a format by what you plan to do next.
Excel
Inspect and edit a workbook. Convenient for small tables and manual review.
CSV or Parquet
Exchange tables with scripts. Flat layouts reduce the number of files and support parsing back into MARIO.
Export the current sets#
Use db.export_sets() to write the current
classifications separately from the matrices:
import mario
db = mario.load_test("SUT")
sets_path = db.export_sets(path="exports/sets.xlsx")
Result · One workbook with Activity, Commodity, Factor of production, Satellite account, Consumption category and Region sheets, plus Scenario. Each sheet has a column with the same MARIO set name and its current members.
Run the export after selecting regions, aggregating classifications or filtering
extensions so the lists describe the transformed database. IOT databases export
Sector instead of Activity and Commodity. Pass include_scenarios=False to
export only the sets listed by db.sets.
When a classification differs between regions, its sheet contains Region
and set-name columns with only the observed region/member pairs. Common sets
remain single-column lists. The method preserves MARIO names and label order;
it does not apply CVXLab mappings. The downloadable companion includes the same
call. Full arguments are in the API reference.
To populate a CVXLab model’s set and input workbooks with its own names and coordinates, follow Prepare CVXLab inputs.
Save and reload#
import mario
db = mario.load_test("IOT")
db.to_parquet(path="iot_export", flows=True, flat=True)
restored = mario.parse_from_parquet(
path="iot_export", table="IOT", mode="flows", flat=True,
)
Result · Exported flow and unit files, then a new database constructed from them. This exports model tables, rather than a Python session.
Excel export
db.to_excel(path="iot_export.xlsx", flows=True, coefficients=True)
See the Excel parser for the required blocks and import options.
CSV export
db.to_txt(path="iot_export_csv", flows=True, _format="csv", flat=True)
restored = mario.parse_from_txt(
path="iot_export_csv", table="IOT", mode="flows",
_format="csv", flat=True,
)
Keep the unit file with the data file. The TXT, CSV and Parquet guide explains flat and matrix layouts.