writeRecordsToCsvFile
writeRecordsToCsvFile(
records,outputPath,columns):Promise<{recordCount:number; }>
Defined in: packages/simply-core/src/csv/createCsvFileWriter.ts:103
Stream every record from an async iterable straight into a CSV file via a single
stream.pipeline() — source -> a counting pass-through -> csv-stringify -> the file. Use
this instead of createCsvFileWriter when every record from a source goes to the same
file unconditionally (e.g. dumping a query’s results to disk); pipeline() wires up
backpressure and error/completion handling for you, so there’s no manual write-loop or
write()/end() bookkeeping. For per-record branching (e.g. routing records to one of several
files based on some condition) or writes from concurrent producers, use
createCsvFileWriter directly instead.
Parameters
Section titled “Parameters”records
Section titled “records”AsyncIterable<Record<string, unknown>>
The records to write, consumed in order as they’re yielded.
outputPath
Section titled “outputPath”string
The filesystem path to write the CSV file to.
columns
Section titled “columns”string[]
The column names to use for the header row and field ordering.
Returns
Section titled “Returns”Promise<{ recordCount: number; }>
The total number of records written.