16 lines
454 B
TypeScript
16 lines
454 B
TypeScript
/**
|
|
* Cuenta filas de datos (excluye 1 línea de encabezado) en un CSV local.
|
|
* Asume primera línea no vacía = encabezado.
|
|
*/
|
|
export async function countCsvDataRows(file: File): Promise<number> {
|
|
const text = await file.text();
|
|
if (!text.trim()) return 0;
|
|
const lines = text.split(/\r\n|\r|\n/);
|
|
let nonEmpty = 0;
|
|
for (const line of lines) {
|
|
if (line.trim().length > 0) nonEmpty += 1;
|
|
}
|
|
if (nonEmpty <= 1) return 0;
|
|
return nonEmpty - 1;
|
|
}
|