Exporting#
This notebook shows a minimal export workflow starting from the packaged IOT test table. It writes the same database to Excel, CSV, and Parquet so you can inspect the output layouts and reuse them in downstream workflows.
[ ]:
import mario
db = mario.load_test("IOT")
INFO Parser: excel reading IOT flows from /Users/lorenzorinaldi/Documents/GitHub/MARIO/mario/test/tables/test_IOT_standard.xlsx.
INFO Parser: state payload ready with 6 canonical blocks.
INFO Parser: excel state ready for IOT.
INFO Metadata: initialized.
Excel export#
to_excel() writes a workbook that can include both flow matrices and coefficient matrices in one file. This is usually the most convenient format when you want to inspect the exported structure manually in Excel.
[ ]:
db.to_excel(
path="/path/to/iot_export.xlsx",
flows=True,
coefficients=True,
)
INFO Export: writing Excel database for baseline.
INFO Resolver: resolving v for baseline.
INFO Resolver: trying v via formula build_iot_v_from_V_X.
INFO Resolver: resolved v via formula build_iot_v_from_V_X.
INFO Resolver: resolving e for baseline.
INFO Resolver: trying e via formula build_iot_e_from_E_X.
INFO Resolver: resolved e via formula build_iot_e_from_E_X.
INFO Resolver: resolving z for baseline.
INFO Resolver: trying z via formula build_iot_z_from_Z_X.
INFO Resolver: resolved z via formula build_iot_z_from_Z_X.
INFO Export: Excel database written.
The exported workbook keeps the familiar matrix-style layout, with separate sheets for the main blocks that MARIO writes.

CSV and Parquet export#
For larger datasets, directory-based exports are often easier to version, inspect, and process outside Excel. With flat=True, MARIO writes one compact data file plus a units file, which is the layout expected by the flat TXT/CSV and Parquet parsers.
[ ]:
db.to_txt(
path="/path/to/iot_export_csv",
flows=True,
_format="csv",
)
INFO Export: writing csv database for baseline in matrix mode.
INFO Export: csv database written.
[ ]:
db.to_txt(
path="/path/to/iot_export_csv",
flows=False,
coefficients=True,
_format="csv",
flat=True,
)
INFO Export: writing csv database for baseline in flat mode.
INFO Export: csv database written.
[ ]:
db.to_parquet(
path="/path/to/iot_export_parquet",
flows=True,
coefficients=True,
flat=True,
)
INFO Export: writing parquet database for baseline in flat mode.
INFO Export: parquet database written.
The flat export layout is more compact than the Excel workbook and is usually the better choice for roundtrip workflows and larger filesystems.

The files written here can be parsed back with the custom TXT/CSV and Parquet parsers described in the parser section of the documentation.