Class CSVFileAbstract
Index
Methods
Methods
StaticasStream
- asStream(
options: { filepath: string; signal?: AbortSignal },
): AsyncGenerator<{ [key: string]: string }>Stream row by row the given CSV file.
Parameters
- options: { filepath: string; signal?: AbortSignal }
Options.
filepath: string
A valid CSV file path.
Optionalsignal?: AbortSignalAbortSignal via AbortController to stop iteration and cleanup streaming.
Returns AsyncGenerator<{ [key: string]: string }>
Asynchronous iterator over each row as an object keyed by column header name.
- options: { filepath: string; signal?: AbortSignal }
StaticgetHeaders
Get CSV column headers defined on the first line of a CSV file.
Parameters
- options: { filepath: string }
Options.
filepath: string
A valid CSV file path.
Returns Promise<string[]>
An array of parsed column headers.
- options: { filepath: string }
StaticgetRows
Return all rows of the given CSV file path.
Parameters
- options: { filepath: string }
Options.
filepath: string
Output CSV file path.
Returns Promise<{ [key: string]: string }[]>
An array of rows as an object keyed by column header name.
- options: { filepath: string }
Staticsave
Save CSV row data to the given file path.
Parameters
- options: { filepath: string; rows: { [key: string]: string }[] }
Options.
filepath: string
Output CSV file path.
rows: { [key: string]: string }[]
CSV row data to write.
Returns Promise<void>
- options: { filepath: string; rows: { [key: string]: string }[] }
Provides a basic API to stream and serialize a CSV file allowing custom programs performing simple filtering / modifications. The CSV files must have a header row describing the column keys.
Example