CSV
Inherits: Resource < RefCounted < Object
Resource containing delimiter-separated values parsed as dictionaries.
Description
CSV stores rows parsed from CSV, TSV, PSV, or other delimiter-separated text. When headers is enabled, the first row is used as dictionary keys. Otherwise rows are stored with numeric column indexes.
Tutorials
Properties
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods
convert_to_variant(text: String) const |
|
get_parser_options() const |
|
load_string(string: String) |
|
save_to_string() const |
Enumerations
enum RowLengthMode: 🔗
RowLengthMode ROW_LENGTH_STRICT = 0
Rejects input when any accepted row has a different field count than the first accepted row.
RowLengthMode ROW_LENGTH_PAD_SHORT = 1
Pads short rows with empty fields and rejects rows that have too many fields.
RowLengthMode ROW_LENGTH_PAD_OR_TRUNCATE = 2
Pads short rows with empty fields and truncates rows that have too many fields.
RowLengthMode ROW_LENGTH_JAGGED = 3
Allows rows to keep their original field counts.
Property Descriptions
PackedStringArray comment_prefixes = PackedStringArray() 🔗
void set_comment_prefixes(value: PackedStringArray)
PackedStringArray get_comment_prefixes()
Lines whose first parsed field begins with any of these prefixes are skipped while loading.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.
The one-character delimiter used while loading and saving.
PackedStringArray false_values = PackedStringArray("false", "False", "FALSE") 🔗
void set_false_values(value: PackedStringArray)
PackedStringArray get_false_values()
Field values that convert_to_variant() and CSV importer methods convert to false.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.
If true, the first parsed row is used as dictionary keys.
PackedStringArray null_values = PackedStringArray("") 🔗
void set_null_values(value: PackedStringArray)
PackedStringArray get_null_values()
Field values that convert_to_variant() and CSV importer methods convert to null.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.
Controls how rows with fewer or more fields than the first accepted row are handled. See RowLengthMode.
Array[Dictionary] rows = [] 🔗
void set_rows(value: Array[Dictionary])
Array[Dictionary] get_rows()
Parsed row dictionaries.
bool skip_empty_rows = false 🔗
If true, rows containing only empty fields are skipped while loading.
If true, leading and trailing whitespace is removed from unquoted fields while loading.
PackedStringArray true_values = PackedStringArray("true", "True", "TRUE") 🔗
void set_true_values(value: PackedStringArray)
PackedStringArray get_true_values()
Field values that convert_to_variant() and CSV importer methods convert to true.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.
Method Descriptions
Variant convert_to_variant(text: String) const 🔗
Converts a field string to a Variant using the same conversion rules as CSVImporter.parse_record().
Dictionary get_parser_options() const 🔗
Returns the parser options generated from this resource's parser properties. The dictionary can be passed to DSVImporter.import_string(), CSVImporter.import_string(), or CSVImporter.parse_record().
Error load_file(path: String) 🔗
Loads delimiter-separated data from path into rows.
Error load_string(string: String) 🔗
Loads delimiter-separated data from string into rows.
String save_to_string() const 🔗
Serializes rows as delimiter-separated text.