Metreeca Gear
    Preparing search index...

    Function csv

    • Creates a CSV parser.

      The generated task reads CSV text and byte streams as streams of records, one Record per data row.

      Chunks are pulled from the source as records are asked for, so sources of any size are handled without holding them in memory and a consumer that stops early releases the source; some chunks are nonetheless read ahead of the records actually consumed, and a source reporting the whole text at once is parsed in one go.

      Warning

      Records that cannot be parsed are skipped and reported to the log, leaving the stream to run to completion.

      Type Parameters

      • R extends Record = Record

        The type of the reported records; field values are reported as parsed, without being validated against it

      Parameters

      • options: {
            header?: boolean;
            skip?: boolean;
            trim?: boolean;
            flex?: boolean;
            quote?: string;
            delimiter?: string;
        } = {}

        The parsing options

        • Optional Readonlyheader?: boolean

          Reads the first row as column labels, keying records by label rather than by positional index; defaults to false

        • Optional Readonlyskip?: boolean

          Ignores empty lines rather than reporting them as records; defaults to false

        • Optional Readonlytrim?: boolean

          Strips surrounding whitespace from field values; defaults to false

        • Optional Readonlyflex?: boolean

          Reports records whose field count doesn't match the header, leaving out missing fields and discarding fields beyond the header, rather than skipping them; defaults to false

        • Optional Readonlyquote?: string

          The character wrapping field values; defaults to " if unset or empty

        • Optional Readonlydelimiter?: string

          The character separating fields; defaults to , if unset or empty

      Returns Task<string | Uint8Array<ArrayBufferLike>, R>

      A task converting a stream of CSV text or byte chunks into a stream of records

      Error While iterating the returned stream, whatever the source reports while producing chunks