import type { DocumentSource, FileInput } from './index.js'; import type { FileLoaderOptions } from './text.js'; /** Options for `parseCsv()`. */ export interface CsvParseOptions { /** The field separator. Defaults to a comma; use `'\t'` for TSV. */ delimiter?: string; } /** * CSV parsed as it arrives: `push()` takes the next piece of text, of any length, and returns the rows * it completed; `end()` returns the last. A quote, or a CRLF, split between two pieces is read as one. * `parseCsv()` is this, given the whole text at once. */ export declare class CsvRowParser { private readonly delimiter; private row; private field; private quoted; /** A quote inside a quoted field, waiting for the next character: a second quote, or the field's end. */ private quote; /** A carriage return that ended a row, whose line feed, if one follows, belongs to it. */ private carriage; private started; constructor(options?: CsvParseOptions); /** Reads the next piece of text, and returns the rows it completed. */ push(text: string): string[][]; /** Ends the text, and returns its last row, unless it ended with a line break. */ end(): string[][]; } /** * Parses CSV into rows of fields, following RFC 4180: quoted fields may hold the delimiter, line * breaks, and doubled quotes; lines may end in CRLF or LF; and a trailing line break adds no row. */ export declare function parseCsv(text: string, options?: CsvParseOptions): string[][]; /** Options for `loadCsv()`. */ export interface CsvLoaderOptions extends FileLoaderOptions, CsvParseOptions { /** * Columns that make up a row's text, written as `column: value` lines. Defaults to every column not * named in `idColumn` or `metadataColumns`. */ textColumns?: readonly string[]; /** The column whose value becomes the row's id, after the file name. Defaults to the row number. */ idColumn?: string; /** Columns copied into the metadata, where a filter can select on them. */ metadataColumns?: readonly string[]; } /** * CSV files, one document per row. The first row names the columns. Each row's text lists its columns * by name, so a model reading a chunk knows what each value is. Rows are read as the file arrives, so * a file larger than memory streams through. */ export declare function loadCsv(inputs: FileInput | Iterable, options?: CsvLoaderOptions): AsyncGenerator;