@maximai/maxim-js
Version:
Maxim AI JS SDK. Visit https://getmaxim.ai for more info.
48 lines (47 loc) • 1.77 kB
TypeScript
export type CSVParseOptions = {
delimiter?: string;
hasHeader?: boolean;
quoteChar?: string;
escapeChar?: string;
};
export type CSVWriteOptions = {
delimiter?: string;
includeHeader?: boolean;
quoteChar?: string;
escapeChar?: string;
};
type ColumnStructure = Record<string, number>;
export declare class CSVFile<T extends ColumnStructure | undefined = undefined> {
private filePath;
private options;
private headerRow;
private rowCount;
private columnCount;
private columnStructure;
private fileStats;
constructor(filePath: string, columnStructure?: T, options?: CSVParseOptions);
private validateHeaders;
private parseRow;
getRowCount(): Promise<number>;
getColumnCount(): Promise<number>;
getHeader(): Promise<string[] | null>;
getRow(index: number): Promise<(T extends ColumnStructure ? {
[K in keyof T]: string;
} : string[]) | null>;
private createTypedRow;
filter(predicate: (row: T extends ColumnStructure ? {
[K in keyof T]: string;
} : string[]) => boolean): Promise<(T extends ColumnStructure ? {
[K in keyof T]: string;
} : string[])[]>;
map<U>(mapper: (row: T extends ColumnStructure ? {
[K in keyof T]: string;
} : string[]) => U): Promise<U[]>;
private processFile;
static restructure<U extends ColumnStructure>(csvFile: CSVFile<ColumnStructure | undefined>, newColumnStructure: U): Promise<CSVFile<U>>;
static writeToFile<T extends ColumnStructure | undefined = undefined>(data: (T extends ColumnStructure ? {
[K in keyof T]: string;
} : string[])[], outputPath: string, columnStructure?: T, options?: CSVWriteOptions): Promise<void>;
private static formatRow;
}
export {};