CSVTable๏
Inherits: RefCounted < Object
Table-style query helper for CSV rows.
Description๏
CSVTable stores CSV data as an array of dictionaries and provides filtering, projection, renaming, grouping, indexing, and join helpers.
Methods๏
apply_model(model: CSVRowModel) const |
|
build_index(column: StringName, unique: bool = false) const |
|
column_names() const |
|
distinct(columns: PackedStringArray = PackedStringArray()) const |
|
drop_columns(columns: PackedStringArray) const |
|
filter_rows(predicate: Callable) const |
|
from_file(path: String, delimiter: String = ",", options: Dictionary = {}) static |
|
from_file_with_dialect(path: String, dialect: CSVDialect) static |
|
get_rows() const |
|
group_by(column: StringName) const |
|
inner_join(other: CSVTable, left_column: StringName, right_column: StringName) const |
|
left_join(other: CSVTable, left_column: StringName, right_column: StringName) const |
|
rename_columns(map: Dictionary) const |
|
row_count() const |
|
select_columns(columns: PackedStringArray) const |
|
void |
|
sort_by(column: StringName, ascending: bool = true) const |
|
sort_by_columns(columns: PackedStringArray, ascending: bool = true) const |
|
validate_model(model: CSVRowModel) const |
|
where_equals(column: StringName, value: Variant) const |
|
where_in(column: StringName, values: Array) const |
|
with_column(column: StringName, value_or_callable: Variant) const |
Method Descriptions๏
CSVTable apply_model(model: CSVRowModel) const ๐
Returns a table with each row cast by model.
CSVIndex build_index(column: StringName, unique: bool = false) const ๐
Builds an index for column. If unique is true, duplicate keys are recorded by the returned CSVIndex.
PackedStringArray column_names() const ๐
Returns all column names found across rows, preserving first-seen order.
CSVTable distinct(columns: PackedStringArray = PackedStringArray()) const ๐
Returns a table containing the first row for each unique key. When columns is empty, the entire row is used as the key.
CSVTable drop_columns(columns: PackedStringArray) const ๐
Returns a table with columns removed from every row.
CSVTable filter_rows(predicate: Callable) const ๐
Returns rows for which predicate returns a truthy value. The callable receives the row and row index.
CSVTable from_csv(csv: CSV) static ๐
Creates a table from a CSV resource's rows.
CSVTable from_file(path: String, delimiter: String = ",", options: Dictionary = {}) static ๐
Loads a header-based CSV file into a table using CSVImporter.import_with_headers().
CSVTable from_file_with_dialect(path: String, dialect: CSVDialect) static ๐
Creates a table by importing path using dialect.
CSVTable from_rows(rows: Array) static ๐
Creates a table from dictionary rows. Array rows are converted to dictionaries using numeric keys.
Returns a copy of the table rows.
Dictionary group_by(column: StringName) const ๐
Groups rows by column, returning a dictionary of key to row arrays.
CSVTable inner_join(other: CSVTable, left_column: StringName, right_column: StringName) const ๐
Returns rows formed by joining this table to other where the join columns match.
CSVTable left_join(other: CSVTable, left_column: StringName, right_column: StringName) const ๐
Returns all rows from this table, joined to matching rows from other when present.
CSVTable limit(count: int, offset: int = 0) const ๐
Returns up to count rows, skipping the first offset rows.
CSVTable map_rows(transform: Callable) const ๐
Returns a table containing dictionaries returned by transform. The callable receives the row and row index.
CSVTable rename_columns(map: Dictionary) const ๐
Returns a table with columns renamed according to map.
Returns the number of rows.
CSVTable select_columns(columns: PackedStringArray) const ๐
Returns a table containing only columns.
void set_rows(rows: Array) ๐
Replaces table rows.
CSVTable sort_by(column: StringName, ascending: bool = true) const ๐
Returns a table stably sorted by column.
CSVTable sort_by_columns(columns: PackedStringArray, ascending: bool = true) const ๐
Returns a table stably sorted by columns in lexicographic order.
Array validate_model(model: CSVRowModel) const ๐
Validates each row with model, returning row-indexed validation reports.
CSVTable where_equals(column: StringName, value: Variant) const ๐
Returns rows where column equals value.
CSVTable where_in(column: StringName, values: Array) const ๐
Returns rows where column matches any value in values.
CSVTable with_column(column: StringName, value_or_callable: Variant) const ๐
Returns a table with column set to a constant value, or to the result of a callable that receives the row and row index.