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
import klyn.io.csv

writer = CSVWriter()
writer.writeRow(["name", "note"])
writer.writeRow(["Ada", "uses, commas"])
print(writer.toString())
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public CSVWriter
CSVWriter( delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = '\u0000', 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 = '\u0000', 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 = '\u0000', 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 = '\u0000', 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 Generator<ArrayList<String>>) as Void throws IOException
Consumes CSV records from a forward-only generator, closing it on every loop exit.
public writeRows
writeRows(rows as IList<ArrayList<String>>) as Void throws IOException
Writes all records from an ordered row list.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, hash, toDict, toJson, toMap, toString, toXml
methodInherited Methods from AutoClosable: close