You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2026. It is now read-only.
I am trying to terminate the parsing and emit the end event.
Here is my code, any help? var csvStream = csv.createStream({ escapeChar: '"', enclosedChar: '"' });
let csvData = {headers: {},rows:[]};
request(req.body.fileUrl).pipe(csvStream)
.on('error', function (err) {
console.error(err);
})
.on('header', function (columns) {
csvData.headers = columns;
console.log(columns);
})
.on('data', async function (data) {
console.log(data);
csvData.rows.push(data);
if (csvData.rows.length >= 100) {
csvStream.emit('end'); // I need only top 100 rows
}
})
.on('end', async function () {
// run the last of the operations
csvData.rows = csvData.rows.slice(0, 10);
return res.send(csvData);
})
.on('column', function (key, value) {
// outputs the column name associated with the value found
console.log('#' + key + ' = ' + value);
});`
I am trying to terminate the parsing and emit the
endevent.Here is my code, any help?
var csvStream = csv.createStream({ escapeChar: '"', enclosedChar: '"' });