@loaders.gl/csv
Version:
Framework-independent loader for CSV and DSV table formats
110 lines • 3.65 kB
TypeScript
export type CSVParserConfig = {
chunk?: boolean;
chunkSize?: number | null;
preview?: number;
newline?: string;
comments?: boolean | string;
skipEmptyLines?: boolean | 'greedy';
delimitersToGuess?: string[];
quotes?: string[] | boolean;
quoteChar?: string;
escapeChar?: string;
delimiter?: string | Function;
fastMode?: boolean;
dynamicTyping?: boolean | {};
dynamicTypingFunction?: Function;
step?: Function;
transform?: Function;
complete?: Function;
};
export declare function CsvToJson(_input: any, _config?: CSVParserConfig, Streamer?: any): any;
/** ChunkStreamer is the base prototype for various streamer implementations. */
export declare class ChunkStreamer {
_handle: any;
_config: any;
_finished: boolean;
_completed: boolean;
_input: null;
_baseIndex: number;
_partialLine: string;
_rowCount: number;
_start: number;
isFirstChunk: boolean;
_completeResults: {
data: never[];
errors: never[];
meta: {};
};
constructor(config: CSVParserConfig);
parseChunk(chunk: any, isFakeChunk?: boolean): any;
_sendError(error: any): void;
}
export declare class ParserHandle {
_config: any;
/** Number of times step was called (number of rows parsed) */
_stepCounter: number;
/** Number of rows that have been parsed so far */
_rowCounter: number;
/** The input being parsed */
_input: any;
/** The core parser being used */
_parser: any;
/** Whether we are paused or not */
_paused: boolean;
/** Whether the parser has aborted or not */
_aborted: boolean;
/** Temporary state between delimiter detection and processing results */
_delimiterError: boolean;
/** Fields are from the header row of the input, if there is one */
_fields: string[];
/** The last results returned from the parser */
_results: {
data: any[][] | Record<string, any>[];
errors: any[];
meta: Record<string, any>;
};
constructor(_config: CSVParserConfig);
/**
* Parses input. Most users won't need, and shouldn't mess with, the baseIndex
* and ignoreLastRow parameters. They are used by streamers (wrapper functions)
* when an input comes in multiple chunks, like from a file.
*/
parse(input: any, baseIndex: any, ignoreLastRow: any): {
data: any[][] | Record<string, any>[];
errors: any[];
meta: Record<string, any>;
} | {
meta: {
paused: boolean;
};
};
paused(): boolean;
pause(): void;
resume(): void;
aborted(): boolean;
abort(): void;
testEmptyLine(s: any): boolean;
processResults(): {
data: any[][] | Record<string, any>[];
errors: any[];
meta: Record<string, any>;
};
needsHeaderRow(): any;
fillHeaderFields(): void;
shouldApplyDynamicTyping(field: any): boolean;
parseDynamic(field: any, value: any): any;
applyHeaderAndDynamicTypingAndTransformation(): {
data: any[][] | Record<string, any>[];
errors: any[];
meta: Record<string, any>;
};
processRow(rowSource: any, i: any): any[] | Record<string, any>;
guessDelimiter(input: any, newline: any, skipEmptyLines: any, comments: any, delimitersToGuess: any): {
successful: boolean;
bestDelimiter: any;
};
addError(type: any, code: any, msg: any, row?: any): void;
}
/** The core parser implements speedy and correct CSV parsing */
export declare function Parser(config?: CSVParserConfig): void;
//# sourceMappingURL=papa-parser.d.ts.map