skipcheck

TM1 client · Docs · Reading and writing data

CellService

from skipcheck_tm1.services import CellService

Used in the walkthroughs Read and write cells, Run a process and read its result.

Cell writes to a cube, by coordinates. Cells are given as Tuples.of maps of dimension to element; reading is through cellsets (CellsetService), and writing into one by ordinal is there too.

Values are numbers for numeric cells and text for string cells; None clears a cell. TM1 (11.8) refuses a write to a consolidated cell (400, CubeCellWriteStatusElementIsConsolidated): it doesn't spread; write the leaves.

tm1.Update takes several cells, but TM1 (11.8) writes only the first, so update takes one; update_cells writes many in one request.

Write one cell, given an element for every dimension of the cube, in order:

# The cell: an element for every dimension of the cube, in the cube's order
cell = {"Version": "Budget", "Region": "North", "Month": "Jan", "Measure": "Revenue"}
tm1.cells.update("Sales", cell, 1200)

Write many cells in one request:

# A budget for North, one value per month, written in one request
budget = {"Jan": 1200, "Feb": 1350, "Mar": 1100}
updates = []
for month, value in budget.items():
    cell = {"Version": "Budget", "Region": "North", "Month": month, "Measure": "Revenue"}
    updates.append(CubeUpdatePatch.builder().bind_tuple(*Tuples.of(cell)).value(value).build())
tm1.cells.update_cells("Sales", updates)

The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncCellService.

Members

updateWrites one value to a cell; tuple maps dimension to element, as for Tuples.of; None clears the cell.
update_cellsWrites many cells, each its own value, in one request.

update

update(cube: str, tuple: Mapping[str, str], value: Any) -> None

tm1.Update: writes one value to a cell; tuple maps dimension to element, as for Tuples.of; None clears the cell.

TM1 REST Action Cube/Update Navigation CellDescriptor/Tuple

update_cells

update_cells(cube: str, updates: Sequence[Any], order: UpdateOrder | None = None) -> None

tm1.UpdateCells: writes many cells, each its own value, in one request: each update CubeUpdatePatch.builder().bind_tuple(*Tuples.of(cell)).value(v), or with a reference cube and cell to copy from. Needs schema 11.0.0.

With order, ByLevel writes leaves before the consolidations above them, so a spread to a consolidation isn't overwritten.

TM1 (11.8) requires a Tuple and a Value in every update (400 otherwise). A ReferenceCube and ReferenceCell didn't change what's written on a leaf, and don't copy that cell's value.

TM1 REST Action Cube/UpdateCells Navigation CubeUpdate/Tuple Navigation CubeUpdate/ReferenceCube Navigation CubeUpdate/ReferenceCell