mario.parse_from_txt#

mario.parse_from_txt(path: str, table: str, mode: str, calc_all: bool = False, year: int = None, name: str = None, source: str = None, model: str = 'Database', sep: str = ',', _format: str | None = None, flat: bool = False, matrix_layouts: dict[str, object] | None = None, tech_assumption: str | None = None, **kwargs)#

Parse a database from a folder of text or CSV files.

Note

This function works with different files to parse the IO data. Each matrix and the units table should be placed in separate delimited files.

Parameters:
  • path (str) – defined the folder that contains data files. When path points to the parent export directory instead of the mode-specific subfolder, MARIO automatically looks for flows or coefficients inside it according to mode.

  • table (str) – acceptable options are ‘IOT’ & ‘SUT’

  • mode (str) –

    defined the base matrices to parse. The options are:

    • flows: needs [Z.*, Y.*, EY.*, V.*, E.*, units.*] in the path

    • coefficients: needs [z.*, Y.*, EY.*, v.*, e.*, units.*] in the path

  • calc_all (boolean) – if True, by default will calculate z,v,e,V,E,Z after parsing

  • year (int, Optional) – optional to the Database (just for recoding the metadata)

  • source (str, Optional) – optional to the Database (just for recoding the metadata)

  • name (str, Optional) – optional but suggested. is useful for visualization and metadata.

  • sep (str, Optional) – separator used in the delimited files.

  • _format (str, Optional) – file extension to parse. Use "txt" or "csv". If omitted, MARIO autodetects the bundle format from the files found in path.

  • flat (bool, Optional) – if True, parse the canonical long-format MARIO text export made of one data file plus one units file, or one units file plus separate long-format files per matrix. Otherwise parse the historical matrix-per-file layout.

  • matrix_layouts (dict, Optional) – optional per-matrix semantic layout declarations for IOT parsers. Accepted values are the same as in parse_from_excel().

Return type:

mario.Database