mafintosh / mafintosh/csv-parser
csv-parser fails when given a stream from `Stream` instead of `fs`
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.5k
- Forks
- 143
- PR merge metrics
- No merged PRs in 30d
Description
- Operating System: Windows 10
- Node Version: 14.17.1
- NPM Version: 6.14.13
- csv-parser Version: 3.0.0
Expected Behavior
Creating a Readable stream and piping it into the parser should result in parsed csv data
Actual Behavior
internal/streams/readable.js:623
throw new ERR_METHOD_NOT_IMPLEMENTED('_read()');
^
Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented
at Readable._read (internal/streams/readable.js:623:9)
at Readable.read (internal/streams/readable.js:462:10)
at maybeReadMore_ (internal/streams/readable.js:610:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'ERR_METHOD_NOT_IMPLEMENTED'
}
How Do We Reproduce?
const Stream = require('stream')
const readableStream = new Stream.Readable()
const csv = require('csv-parser')
const fs = require("fs")
const results = [];
fs.createReadStream('csvTest.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
// [
// { NAME: 'Daffy Duck', AGE: '24' },
// { NAME: 'Bugs Bunny', AGE: '22' }
// ]
});
readableStream.push(`example,csv,data
line,two,is
not,needed,but
I,made,one
anyway,0,1`)
readableStream.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
// [
// { NAME: 'Daffy Duck', AGE: '24' },
// { NAME: 'Bugs Bunny', AGE: '22' }
// ]
});
both methods of creating a stream should result in the exact same output, as they have the exact same input.
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 by running the Node.js reproduction in the issue with both fs.createReadStream and the manually created Readable, then inspect csv-parser's stream entry point. Confirm whether the parser receives equivalent input and whether both cases produce the expected parsed rows; the issue is done when the reported error is resolved without changing the fs-stream output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100