CSVWriter

Inherits: RefCounted < Object

Streaming CSV writer with Variant stringification.

Description

CSVWriter wraps DSVWriter and converts Variants with CSVExporter.stringify() while writing rows incrementally.

Properties

bool

color_as_hex

false

PackedStringArray

header_names

PackedStringArray()

bool

headers

false

bool

hex_include_alpha

false

Methods

void

close()

Error

get_error() const

Error

open(file_path: String, delimiter: String = ",", append: bool = false)

bool

write_row(row: Variant)

bool

write_rows(rows: Array)


Property Descriptions

bool color_as_hex = false 🔗

  • void set_color_as_hex(value: bool)

  • bool get_color_as_hex()

If true, Color values are written as HTML color strings.


PackedStringArray header_names = PackedStringArray() 🔗

Header names and dictionary output order used when headers is enabled.

Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.


bool headers = false 🔗

  • void set_headers(value: bool)

  • bool get_headers()

If true, writes one header row before the first data row.


bool hex_include_alpha = false 🔗

  • void set_hex_include_alpha(value: bool)

  • bool get_hex_include_alpha()

If true, HTML color strings include alpha when color_as_hex is enabled.


Method Descriptions

void close() 🔗

Closes the current output file.


Error get_error() const 🔗

Returns the last error from the underlying DSVWriter.


Error open(file_path: String, delimiter: String = ",", append: bool = false) 🔗

Opens file_path for streaming writes. If append is true, rows are appended to an existing file when possible.


bool write_row(row: Variant) 🔗

Writes one row. If headers is enabled and row is a Dictionary, header_names controls the output field order.


bool write_rows(rows: Array) 🔗

Writes each row in rows.