Runs the computations needed to get the contents of the Pathway Live Data Framework Table and converts it to a dictionary representation, where each column is mapped to its respective values. Args: table (Table): The Pathway Live Data Framework Table to be converted. **
(
table: Table,
**kwargs,
)
| 58 | |
| 59 | |
| 60 | def table_to_dicts( |
| 61 | table: Table, |
| 62 | **kwargs, |
| 63 | ) -> tuple[list[api.Pointer], dict[str, dict[api.Pointer, api.Value]]]: |
| 64 | """ |
| 65 | Runs the computations needed to get the contents of the Pathway Live Data Framework Table and converts it |
| 66 | to a dictionary representation, where each column is mapped to its respective values. |
| 67 | |
| 68 | Args: |
| 69 | table (Table): The Pathway Live Data Framework Table to be converted. |
| 70 | **kwargs: Additional keyword arguments to customize the behavior of the function. |
| 71 | - terminate_on_error (bool): If True, the function will terminate execution upon |
| 72 | encountering an error during the squashing of updates. Defaults to True. |
| 73 | |
| 74 | Returns: |
| 75 | tuple: A tuple containing two elements: 1) list of keys (pointers) that represent |
| 76 | the rows in the table, and 2) a dictionary where each key is a column name, |
| 77 | and the value is another dictionary mapping row keys (pointers) to their respective |
| 78 | values in that column. |
| 79 | """ |
| 80 | captured = _compute_tables(table, **kwargs)[0] |
| 81 | output_data = api.squash_updates( |
| 82 | captured, terminate_on_error=kwargs.get("terminate_on_error", True) |
| 83 | ) |
| 84 | keys = list(output_data.keys()) |
| 85 | columns = { |
| 86 | name: {key: output_data[key][index] for key in keys} |
| 87 | for index, name in enumerate(table._columns.keys()) |
| 88 | } |
| 89 | return keys, columns |
| 90 | |
| 91 | |
| 92 | @functools.total_ordering |
no test coverage detected