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๏
from_schema(schema: Dictionary) static |
|
get_field_names() const |
|
get_schema() const |
|
infer_from_rows(rows: Array, options: Dictionary = {}) static |
|
infer_from_table(table: CSVTable, options: Dictionary = {}) static |
|
load_schema(path: String) |
|
save_schema(path: String) const |
|
serialize_row(row: Variant, include_defaults: bool = true) const |
|
serialize_rows(rows: Array, include_defaults: bool = true) const |
|
void |
set_schema(schema: Dictionary) |
validate_row(row: Variant) const |
|
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.