mafintosh / mafintosh/csv-parser
Pass original row in "on" callback
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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