baml.csv.Record
One raw CSV record. Yielded by iterating a `Reader`.
Signature
class baml.csv.RecordOne raw CSV record. Yielded by iterating a Reader.
Where Python's csv.DictReader hands you a finished dict of strings, a
Record converts on demand: get<int>("amount") reads one cell and leaves
the others untouched. to_map() is there when you do want the whole dict.
Records are snapshots and stay valid after the reader advances. Each one carries the headers in force when it was read, so name-based access keeps working on a record you held onto.
The cell-decodable types, shared by get, get_at, and decode, are
string, int, bigint, float, bool, any enum (matched against
variant names), baml.time.Instant, baml.time.PlainDate,
baml.time.PlainDateTime, and optionals of those. Any other T is a
configuration mistake, not a data problem, and throws
Error { kind: Options }.
A "null cell" is an unquoted cell that is empty or matches
ReaderOptions.null_values; quoting a cell always makes it data. The one
asymmetry: an empty cell read as T = string is "", not null, since an
empty string is a perfectly good string and CSV cannot tell the two apart.
Source:<builtin>/baml/ns_csv/csv.bamlbytes 9899–13551
Fields
_handle
$rust_typeInstance methods
Applies the full typed-decode rules to this one record — useful for routing heterogeneous rows.
Always throws on failure, whatever the reader's on_error policy says.
T must be a flat class. Each field is matched to a column by its
declared name (no @alias), or positionally by declaration order when
the reader has no headers. An optional field tolerates an absent
column, a missing cell, and a null cell; a required one tolerates none
of the three.
Throws
Error { kind: Decode }when a cell will not convert, or when a required field's cell is missing or null.Error { kind: Header }when a required field has no matching column, or its column name is duplicated.Error { kind: Options }whenTis not a class, or a field's type is not cell-decodable.
fields
(self) -> string[]Converts the cell under header column to T.
Returns
null for a column name absent from the headers, a missing cell, or a
null cell.
Throws
Error { kind: Decode }when a cell exists but cannot convert toT.Error { kind: Header }when the name is duplicated in the header, or when name-based access is used with no headers at all — useget_atfor positional access.Error { kind: Options }whenTis not cell-decodable.
Converts the cell at index to T, positionally.
Works with or without headers. An out-of-range or negative index
reads as a missing cell rather than an error.
Returns
null for a missing or null cell.
Throws
Error { kind: Decode }on conversion failure.Error { kind: Options }whenTis not cell-decodable.
length
(self) -> intImplementations
baml.Concrete for T
Source:<builtin>/baml/core.bamlbytes 747–779