ts_shape.loader.metadata.workbook
Read a plant's datapoint workbook (.xlsx) without extra dependencies.
A datapoint export is often delivered as a workbook: one row per datapoint
with uuid, label and the flattened configuration as config.<key>
columns (config.nodePath[string], config.unit, ...), next to plain
columns such as is_enabled, is_archived, scaling_factor and
scaling_offset. It is the flat form of the JSON that
:class:~ts_shape.loader.metadata.metadata_json_loader.MetadataJsonLoader
reads.
- :func:
read_workbookreads one sheet as a frame (header in the first row) with the Python standard library only (zipfile+ XML), so no Excel package is needed; - :func:
nested_recordsturns such a flat frame into the records with a nestedconfigdict the JSON loader takes.
| Name | Description |
|---|---|
read_workbook | One sheet of an .xlsx as a frame (header in row 1). |
nested_records | Records with a nested config from a flat datapoint table. |
read_workbook
read_workbook(path: str | Path, sheet: int | str = 0) -> pd.DataFrame
One sheet of an .xlsx as a frame (header in row 1).
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | The workbook file. | required |
sheet | int | str | Sheet position (0 = first) or name. | 0 |
| Type | Description |
|---|---|
DataFrame | One row per non-empty sheet row; text, numbers (integral numbers as |
DataFrame | int) and booleans as stored. Empty cells are missing. |
| Type | Description |
|---|---|
FileNotFoundError | When path does not exist. |
ValueError | When the file is not a workbook or has no such sheet. |
nested_records
nested_records(frame: pd.DataFrame) -> list[dict[str, Any]]
Records with a nested config from a flat datapoint table.
config.<key> and config.<key>[type] columns become keys of the
record's config dict (the [type] suffix of an export is
dropped); every other column stays at the top level. Missing values are
left out.