darcyai.output.csv_output_stream
CSVOutputStream Objects
class CSVOutputStream(OutputStream)
OutputStream implementation that writes to a CSV file.
Arguments
- file_path (
str
): The path to the CSV file to write to. - delimiter (
str
): The delimiter to use in the CSV file. Defaults to,
. - quotechar (
str
): The quote character to use in the CSV file. Defaults to|
. - buffer_size (
int
): The size of the buffer to use when writing to theCSV file. Defaults to0
. - flush_interval (
int
): The number of seconds before flushing the buffer to disk. Defaults to0
.
Examples
>>> from darcyai.output.csv_output_stream import CSVOutputStream
>>> csv_output_stream = CSVOutputStream(file_path="output.csv",
delimiter=",",
quotechar="|",
buffer_size=1024*1024,
flush_interval=0)
write
def write(data: list) -> None
Writes the given data to the CSV file.
Arguments
- data (
list
): The data to write to the CSV file.
Examples
>>> from darcyai.output.csv_output_stream import CSVOutputStream
>>> csv_output_stream = CSVOutputStream(file_path="output.csv",
delimiter=",",
quotechar="|",
buffer_size=1024*1024,
flush_interval=0)
>>> csv_output_stream.write([["a", "b", "c"], ["d", "e", "f"]])
close
def close() -> None
Closes the CSV file.
Examples
>>> from darcyai.output.csv_output_stream import CSVOutputStream
>>> csv_output_stream = CSVOutputStream(file_path="output.csv",
delimiter=",",
quotechar="|",
buffer_size=1024*1024,
flush_interval=0)
>>> csv_output_stream.close()