Skip to content

countCsvRows

countCsvRows(filePath): Promise<number>

Defined in: countCsvRows.ts:34

Count the data rows in a CSV, excluding its header.

Parses rather than counting newlines: a quoted field may contain line breaks, so \n counting over-reports and would budget for uploads that never happen. The parser options match the ones the upload itself uses, so the count and the work cannot disagree.

This reads the file a second time rather than buffering the parsed rows. The trade is a cheap sequential local read against unbounded memory on exactly the large inputs where checking the budget matters most.

string

Path to the CSV.

Promise<number>

The number of data rows.