@Js
CsvInStream is used to read delimiter-separated values as specified by RFC 4180. Format details:
- rows are delimited by a newline
- cells are separated by delimiter char
- cells may be quoted with
"
character - quoted cells may contain the delimiter
- quoted cells may contain newlines (always normalized to "\n")
- quoted cells must escape
"
with""
- the trim flag trims leading/trailing whitespace from non-quoted cells (note that RFC 4180 specifies that whitespace is signficant)
Also see CsvOutStream
.
Slots
- delimiterSource
-
Int delimiter := 44
Delimiter character; defaults to comma.
- eachRowSource
-
Iterate through all the lines parsing each one into delimited-separated strings and calling the given callback functions. The input stream is guaranteed to be closed upon completion.
-
private Str? line
- makeSource
-
new make(InStream in)
Wrap the underlying input stream.
-
private Str parseCell()
-
private Str parseNonQuotedCell()
-
private Str parseQuotedCell()
-
private Int pos
- readAllRowsSource
-
Str[][] readAllRows()
Read the entire table of rows into memory. The input stream is guaranteed to be closed upon completion.
- readRowSource
-
virtual Str[]? readRow()
Read the next line as a row of delimiter-separated strings. Return null if at end of stream.
-
private Int rowWidth := 10
- trimSource
-
Bool trim := true
Configures whether unqualified whitespace around a cell is automatically trimmed. If a field is enclosed by quotes then it is never trimmed.