mafintosh/csv-parser

Pass original row in "on" callback

v-tadipatri opened this issue · 0 comments

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

});