mafintosh / mafintosh/csv-parser

Pass original row in "on" callback

Open
#173 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.5k
Forks
143
PR merge metrics
No merged PRs in 30d

Description

### 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

});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the csv() entry point and follow the .on('data') callback path to understand how parsed data is emitted. Decide how the original line should be represented alongside the JSON data, then verify that callbacks receive both values while preserving existing parsing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.