CSVWriter
classin packageklyn.io.csv
public class CSVWriter extends Object implements AutoClosable:
└ CSVWriter
All Implemented Interfaces: AutoClosable

CSV writer inspired by Python's csv.writer.

The writer supports the common CSV dialect knobs: delimiter, quote character, escape character, double-quote escaping, line terminator and quoting mode (minimal, all, none).

@example `klyn import klyn.io.csv

writer = CSVWriter() writer.writeRow(["name", "note"]) writer.writeRow(["Ada", "uses, commas"]) print(writer.toString())

Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public CSVWriter
CSVWriter( delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = Char(0), doubleQuote as Boolean = true, lineTerminator as String = "\r\n", quoting as String = "minimal" ):
Creates a buffered CSV writer.
public CSVWriter
CSVWriter( filename as String, delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = Char(0), doubleQuote as Boolean = true, lineTerminator as String = "\r\n", quoting as String = "minimal" ):
Creates a CSV writer backed by a file name.
public CSVWriter
CSVWriter( path as Path, delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = Char(0), doubleQuote as Boolean = true, lineTerminator as String = "\r\n", quoting as String = "minimal" ):
Creates a CSV writer backed by a file path.
public CSVWriter
CSVWriter( writer as TextWriter, delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = Char(0), doubleQuote as Boolean = true, lineTerminator as String = "\r\n", quoting as String = "minimal" ):
Creates a CSV writer on an existing text writer.
Methods
Modifier and Type Member Description
public override close
close() as Void throws IOException:
Closes the underlying writer when one was provided.
public override toString
toString() as String:
Returns the generated CSV text.
public writeRow
writeRow(row as IList<String>) as Void throws IOException:
Writes one CSV record.
public writeRows
writeRows(rows as IList<ArrayList<String>>) as Void throws IOException:
Writes all records from an ordered row list.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Methods inherited from AutoClosable: close