Streaming CSV Reader
Adds CsvReader.stream(Reader), returning a new CsvStreamReader class: a genuinely
streaming, row-at-a-time CSV reading API for documents too large to comfortably load
into memory as a single List<List<String>>.
CsvStreamReaderimplementsIterator<List<String>>,Iterable<List<String>>, and
Closeable— use it directly withhasNext()/next(), or as the target of an
enhancedforloop.- Reads incrementally from the underlying
Reader, never buffering more than the
current row's fields. - Applies the exact same character-level dialect rules as
CsvReader.parse(Reader):
quoted fields, embedded commas/newlines (\nand\r\n), and escaped ("") quotes.
Testing
- A new test parses a 50,000-row CSV (mixing plain, comma-quoted, newline-quoted, and
escaped-quote fields) both throughCsvReader.parse(Reader)and through
CsvStreamReader, each driven from its own realFileReaderover a temp file, and
asserts the results are identical row-for-row. - A second new test proves the reader doesn't buffer the whole document up front, by
tracking exact character consumption through a customReaderand asserting only a
small prefix is read after pulling the first row. - All existing
CsvReaderTestandCsvWriterTestregression suites still pass
unchanged.
See CHANGELOG.md
for full details.