CSVReader
Inherits: RefCounted < Object
Streaming CSV reader with Variant conversion.
Description
CSVReader wraps DSVReader and converts each streamed field with CSVImporter.parse_record(). It can return each row as an Array or, when headers are enabled, as a Dictionary keyed by the first accepted row.
Properties
|
||
|
Methods
void |
close() |
get_error() const |
|
get_header_names() const |
|
get_length() const |
|
get_line() const |
|
get_position() const |
|
is_eof() const |
|
open(file_path: String, delimiter: String = ",", headers: bool = false, cast_fields: bool = true, options: Dictionary = {}) |
|
open_with_dialect(file_path: String, dialect: CSVDialect) |
|
read_row() |
|
Property Descriptions
If true, streamed fields are converted with CSVImporter.parse_record().
If true, the first accepted row is used as dictionary keys for later rows.
Method Descriptions
void close() 🔗
Closes the current file and resets the reader.
Returns the last error from the underlying DSVReader.
PackedStringArray get_header_names() const 🔗
Returns the header names read from the first accepted row when headers is enabled.
Returns the current file length in bytes, or 0 when no file is open.
Returns the current one-based input line number.
Returns the current file byte position, or 0 when no file is open.
Returns true when the file has been fully read and no parsed rows remain.
Error open(file_path: String, delimiter: String = ",", headers: bool = false, cast_fields: bool = true, options: Dictionary = {}) 🔗
Opens file_path for streaming reads. If headers is true, the first accepted row is consumed as dictionary keys. If cast_fields is true, each field is converted to a Variant.
Error open_with_dialect(file_path: String, dialect: CSVDialect) 🔗
Opens file_path using dialect.
Reads one row. Returns an Array when headers is false, a Dictionary when headers is true, or null at EOF or after an error.
Array read_rows(max_rows: int = 0) 🔗
Reads up to max_rows rows. If max_rows is 0, reads until EOF.