CSVRowModel๏ƒ

Inherits: RefCounted < Object

Schema-driven typed row converter for CSV data.

Description๏ƒ

CSVRowModel stores a dictionary schema and applies it to CSV rows. It can cast dictionaries or array rows into typed dictionaries, apply defaults, validate required fields and enum values, and serialize rows for CSV export.

Methods๏ƒ

Dictionary

cast_row(row: Variant) const

Array

cast_rows(rows: Array) const

CSVRowModel

from_file(path: String) static

CSVRowModel

from_schema(schema: Dictionary) static

PackedStringArray

get_field_names() const

Dictionary

get_schema() const

CSVRowModel

infer_from_rows(rows: Array, options: Dictionary = {}) static

CSVRowModel

infer_from_table(table: CSVTable, options: Dictionary = {}) static

Error

load_schema(path: String)

Error

save_schema(path: String) const

Dictionary

serialize_row(row: Variant, include_defaults: bool = true) const

Array

serialize_rows(rows: Array, include_defaults: bool = true) const

void

set_schema(schema: Dictionary)

Dictionary

validate_row(row: Variant) const

Array

validate_rows(rows: Array) const


Method Descriptions๏ƒ

Dictionary cast_row(row: Variant) const ๐Ÿ”—

Returns a typed dictionary for row, applying defaults where available.


Array cast_rows(rows: Array) const ๐Ÿ”—

Casts each row in rows.


CSVRowModel from_file(path: String) static ๐Ÿ”—

Creates a row model by loading a schema dictionary from path.


CSVRowModel from_schema(schema: Dictionary) static ๐Ÿ”—

Creates a row model from schema.


PackedStringArray get_field_names() const ๐Ÿ”—

Returns schema field names in declaration order.


Dictionary get_schema() const ๐Ÿ”—

Returns a copy of the current schema.


CSVRowModel infer_from_rows(rows: Array, options: Dictionary = {}) static ๐Ÿ”—

Creates a model by inferring schema definitions from dictionaries or array rows. String values are parsed with DotCSV conversion rules before type inference.


CSVRowModel infer_from_table(table: CSVTable, options: Dictionary = {}) static ๐Ÿ”—

Creates a model by inferring schema definitions from the rows in table.


Error load_schema(path: String) ๐Ÿ”—

Loads a schema dictionary from path and replaces the current schema.


Error save_schema(path: String) const ๐Ÿ”—

Saves the current schema dictionary to path.


Dictionary serialize_row(row: Variant, include_defaults: bool = true) const ๐Ÿ”—

Returns a dictionary suitable for CSV export. Values are cast first; missing defaulted fields are included when include_defaults is true.


Array serialize_rows(rows: Array, include_defaults: bool = true) const ๐Ÿ”—

Serializes each row in rows.


void set_schema(schema: Dictionary) ๐Ÿ”—

Replaces the current schema.


Dictionary validate_row(row: Variant) const ๐Ÿ”—

Validates row and returns a report with ok, errors, and casted row data.


Array validate_rows(rows: Array) const ๐Ÿ”—

Validates each row and includes its row index in each report.