Skip to main content
Module

x/csv/reader.ts>CSVReader

Streaming API for reading and writing CSV for https://deno.land/
Go to Latest
class CSVReader
import { CSVReader } from "https://deno.land/x/csv@v0.3.0/reader.ts";

Class for manual CSV reading:

  let row: string[] = [];
  const reader = new CSVReader(f, {
    columnSeparator: "\t",
    lineSeparator: "\r\n",
    onCell(cell: string) {
      row.push(cell);
    },
    onRowEnd() {
      console.log(row);
      row = [];
    },
    onEnd() {
      console.log('end');
    },
    onError(err) {
      console.error(err);
    }
  });
  reader.read();

Constructors

new
CSVReader(reader: Deno.Reader, options?: Partial<CSVReaderOptions>)

Properties

private
_columnBufferMinStepSize: number
private
_inputBufferIndexLimit: number
private
_readerIteratorBufferSize: number
private
_stats: { reads: number; inputBufferShrinks: number; columnBufferExpands: number; }
private
columnBuffer: Uint8Array
private
columnBufferIndex: number
private
columnBufferStepSize: number
private
columnSeparator: Uint8Array
private
debug: (msg: string) => void
private
decoder: TextDecoder
private
doubleQuote: Uint8Array
private
emptyLine: boolean
private
inColumn: boolean
private
inputBuffer: Uint8Array
private
inputBufferIndex: number
private
inputBufferUnprocessed: number
private
inQuote: boolean
private
lineSeparator: Uint8Array
private
minPossibleBufferReserve: number
private
onCell: (cell: string) => void
private
onEnd: () => void
private
onError: (err: Error) => void
private
onRowEnd: () => void
private
paused: boolean
private
quote: Uint8Array
private
readerEmpty: boolean
private
readerIterator: AsyncIterableIterator<Uint8Array>

Methods

private
hasNext(chars: Uint8Array)
private
parseCycle()
private
processColumn()
private
processRow()
private
readChars(n: number)
private
readMoreData()
private
skip(chars: Uint8Array)