web / lib/utils/file-readers
lib/utils/file-readers
Provides utility functions for reading data from files in batches.
This module is designed to efficiently process large CSV or Excel files without loading
the entire file into memory. It offers a readBatchFromFile function that can read a
specific chunk of rows from a file, which is essential for the background job processing
of large data imports. It also provides a helper to get the total row count of a file.
Functions
readBatchFromFile()
readBatchFromFile(
filePath,options):Record<string,unknown>[]
Read a batch of rows from a file (CSV or Excel).
Parameters
filePath
string
options
ReadBatchOptions
Returns
Record<string, unknown>[]
readAllRowsFromFile()
readAllRowsFromFile(
filePath,options):Record<string,unknown>[]
Read all rows from a file (CSV or Excel). Uses batch reading internally but returns all rows at once.
Parameters
filePath
string
options
ReadAllOptions = {}
Returns
Record<string, unknown>[]
getFileRowCount()
getFileRowCount(
filePath,sheetIndex):number
Get total row count from a file.
Parameters
filePath
string
sheetIndex
number = 0
Returns
number