CsvReader
A class to read and process CSV data.
Constructors
Constructor
new CsvReader(
csv,options?):CsvReader
Creates an instance of CsvReader.
Parameters
csv
string
The CSV string to read.
options?
Configuration options for reading the CSV.
Returns
CsvReader
Methods
readLines()
readLines(
onLineRead):void
Read each line consecutively and call a function with an array representing each line.
Parameters
onLineRead
(entries) => void
Function to call with an array of strings for each line.
Returns
void
readRecords()
readRecords(
onRecordRead):void
Read each line consecutively and call a function with a record (object) representing each line. If headers are available, they are used as keys; otherwise, "Field 1", "Field 2", etc. are used.
Parameters
onRecordRead
(record) => void
Function to call with a record object for each line.
Returns
void