Skip to content

model.csv

Inspect CSV columns and configure their import.

2 functions / 5 types

Index

FunctionDescription
inspectInspects a CSV file and proposes a column configuration.
inspect_stringInspects CSV text and proposes a column configuration.
TypeDescription
AttributeTypeThe roles an attribute can have, one arm per role, so measurement semantics exist only on the role that is read under them.
HeaderConfigHow one CSV column becomes a model attribute.
HeaderConfigMapHow each CSV column becomes a model attribute, keyed by column name.
RealMeasurementKindHow a numeric attribute relates to the size of the thing it describes.
UnitConversionConverts an imported column’s values to the units the model uses.

inspect

def inspect(
    *,
    path: str,
    _transaction_id: str | None = None
) -> types.model.csv.HeaderConfigMap

Inspects a CSV file and proposes a column configuration.

Returns HeaderConfigMap.

path : str

Path to the CSV

_transaction_id optional : str | None

Transaction to join. Omit to submit without an explicit transaction. Defaults to None.

inspect_string

def inspect_string(
    *,
    csv: str,
    _transaction_id: str | None = None
) -> types.model.csv.HeaderConfigMap

Inspects CSV text and proposes a column configuration.

Returns HeaderConfigMap.

csv : str

CSV content. Only the header row plus the first few data rows are inspected.

_transaction_id optional : str | None

Transaction to join. Omit to submit without an explicit transaction. Defaults to None.

AttributeType

AttributeType()

The roles an attribute can have, one arm per role, so measurement semantics exist only on the role that is read under them.

Construct one of the nested classes. Use isinstance to check its type.

AttributeType.X

AttributeType.X()

X position column.

AttributeType.Y

AttributeType.Y()

Y position column.

AttributeType.Z

AttributeType.Z()

Z position column.

AttributeType.Dx

AttributeType.Dx()

Block extent along the X axis.

AttributeType.Dy

AttributeType.Dy()

Block extent along the Y axis.

AttributeType.Dz

AttributeType.Dz()

Block extent along the Z axis.

AttributeType.Real

AttributeType.Real(value: types.model.csv.RealMeasurementKind)

A floating-point attribute, with the measurement semantics it is read under.

AttributeType.String

AttributeType.String()

A string attribute.

AttributeType.Rgb

AttributeType.Rgb()

An RGB color attribute.

AttributeType.Int

AttributeType.Int()

An integer attribute.

AttributeType.Normal

AttributeType.Normal()

A normal vector attribute.

AttributeType.Bool

AttributeType.Bool()

A boolean attribute.

HeaderConfig

HeaderConfig(
    *,
    kind: types.model.csv.AttributeType | None = None,
    rename: str | None = None,
    unit_conversion: types.model.csv.UnitConversion | None = None
)

How one CSV column becomes a model attribute.

kind optional : AttributeType | None

The attribute role this column maps to. Defaults to None.

rename optional : str | None

Override for the attribute’s name. When absent, the source name is kept. Defaults to None.

unit_conversion optional : UnitConversion | None

Linear conversion applied to the column’s values. When absent, none is applied. Defaults to None.

HeaderConfigMap

HeaderConfigMap(*, columns: dict[str, types.model.csv.HeaderConfig] = <factory>)

How each CSV column becomes a model attribute, keyed by column name.

columns : dict[str, HeaderConfig]

One entry per column, keyed by the column’s name in the CSV header row.

RealMeasurementKind

Enum

class RealMeasurementKind(IntEnum)

How a numeric attribute relates to the size of the thing it describes.

Values: INDEPENDENT_VALUE = 0 Value independent of the object’s geometry. VALUE_BY_WEIGHT = 1 Value scaling with the object’s volume and density. VALUE_BY_VOLUME = 2 Value scaling with the object’s volume. DENSITY = 3 The object’s density.

INDEPENDENT_VALUE = 0

Value independent of the object’s geometry.

VALUE_BY_WEIGHT = 1

Value scaling with the object’s volume and density.

VALUE_BY_VOLUME = 2

Value scaling with the object’s volume.

DENSITY = 3

The object’s density.

UnitConversion

UnitConversion(*, scale: float, offset: float)

Converts an imported column’s values to the units the model uses.

scale : float

Multiplier applied to each source value.

offset : float

Constant added after scaling.