mafintosh / csv-parser

Streaming csv parser inspired by binary-csv that aims to be faster than everyone else
MIT License
1.41k stars 134 forks source link

Pass original row in "on" callback #173

Open v-tadipatri opened 4 years ago

v-tadipatri commented 4 years ago

Feature Proposal

I've found the csv-parser quite useful,but I thought it would be nice if the on(data) callback passed the original line that was read: Is there some way the callback for data could provide the json form of the data as well as the original line? Not sure what the best way is to do this, but it would be useful to have both.

Feature Use Case

fs.createReadStream(myfile) .pipe(csv()) //If rawline won't work here, perhaps you could make it a field inside the data .on('data', (data, rawline) => { if (data.field1=='something'){ console.log("Original line:"+rawline) } }) .on('end', () => { //do something

});