morphogen.io.tables

Tables of results as raw data files: comma-separated values (.csv), text in tab-separated columns under a # header (.txt, .tsv: numpy.loadtxt reads them) and Excel workbooks (.xlsx), without dependency: a workbook is a zip of a few XML parts (Office Open XML), its strings inline, its header row bold and frozen.

A table is a list of records (dicts), a mapping of columns (name -> values) or a 2D array (with header); several tables (a mapping name -> table) become the sheets of a workbook, or one text file each.

morphogen.io.tables.as_columns(table, header=None) → tuple[list[str], list[list]][source]

The header and the columns (lists) of a table (records, columns or an array).

morphogen.io.tables.write_table(path, table, *, header=None, sheet: str = 'data', precision: int | None = None) → Path[source]

Write a table to .csv, .txt/.tsv/.dat or .xlsx (by its suffix); precision significant digits for the text formats (all by default).

morphogen.io.tables.write_tables(path, tables: dict, *, precision: int | None = None) → list[Path][source]

Several tables: the sheets of one .xlsx workbook, or one text file each (<stem>_<name><suffix>).

morphogen.io.tables.read_table(path, sheet: int = 0) → dict[str, list][source]

The columns (name -> values) of a table written by write_table() (or any simple .csv, text or .xlsx table with a header row).