model.csv
Inspect CSV columns and configure their import.
2 functions / 5 types
Index
| Function | Description |
|---|---|
| inspect | Inspects a CSV file and proposes a column configuration. |
| inspect_string | Inspects CSV text and proposes a column configuration. |
| Type | Description |
|---|---|
| AttributeType | The roles an attribute can have, one arm per role, so measurement semantics exist only on the role that is read under them. |
| HeaderConfig | How one CSV column becomes a model attribute. |
| HeaderConfigMap | How each CSV column becomes a model attribute, keyed by column name. |
| RealMeasurementKind | How a numeric attribute relates to the size of the thing it describes. |
| UnitConversion | Converts an imported column’s values to the units the model uses. |
inspect
def inspect(
*,
path: str,
_transaction_id: str | None = None
) -> types.model.csv.HeaderConfigMapInspects 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.HeaderConfigMapInspects 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.
value : RealMeasurementKind
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.