CSVReader
classin packageklyn.io.csv
public class CSVReader extends Generator<ArrayList<String>>
└ CSVReader

Lazy, forward-only CSV record generator with RFC-4180 style quoting.

Files are decoded incrementally through a reusable 64 KiB byte buffer. A borrowed TextReader is consumed one physical line at a time. Only the input buffer and the current record are retained, including for quoted fields containing delimiters, CR/LF newlines and escaped quotes. Records already returned remain independent of subsequent reads.

There is no size or random-access API. Use readRows() to explicitly collect the remaining records. A completed or closed reader cannot be restarted. for closes its generator on every exit, including break and exceptions.

Example
import klyn.io.csv

try reader = CSVReader("contacts.csv", delimiter=';'):
    reader.skip(1)
    for row in reader:
        print(row.join(" | "))
Properties
Modifier and Type Member Description
public override readonly property current
current as ArrayList<String>
Returns the record produced by the last successful next(), without advancing.
Inherited Properties
propertyInherited Properties from Generator: current
Constructors
Modifier and Type Member Description
public CSVReader
CSVReader( filename as String, delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = '\u0000', doubleQuote as Boolean = true, skipInitialSpace as Boolean = false, strict as Boolean = true, encoding as String = "auto" )
Opens a CSV file without parsing its records.
public CSVReader
CSVReader( path as Path, delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = '\u0000', doubleQuote as Boolean = true, skipInitialSpace as Boolean = false, strict as Boolean = true, encoding as String = "auto" )
Opens a CSV path without parsing its records.
public CSVReader
CSVReader( reader as TextReader, delimiter as Char = ',', quoteChar as Char = '"', escapeChar as Char = '\u0000', doubleQuote as Boolean = true, skipInitialSpace as Boolean = false, strict as Boolean = true )
Creates an unstarted CSV cursor over the remaining text of a reader.
Methods
Modifier and Type Member Description
public override close
close() as Void
Closes this cursor idempotently and releases its buffers and current row.
public override next
next() as Boolean
Parses exactly the next CSV record, which may span physical input lines.
public readRows
readRows() as ArrayList<ArrayList<String>>
Explicitly materializes all remaining records and exhausts this cursor.
public rows Alias for readRows(), explicitly collecting all remaining CSV records.
public skip
skip(count as Long) as Void
Consumes the next count records without accumulating them.
Inherited Methods
methodInherited Methods from Generator: close, next