Missing header in output when input has only header
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4.3k
- Forks
- 299
- Avg merge
- 16h 19m
- Merged PRs (30d)
- 1
Description
Hi there,
The following code
const inputFilePath = 'test_in.csv';
const outputCsv = fs.createWriteStream('test_out.csv');
fs.createReadStream(inputFilePath)
.pipe(csv.parse({ columns: true }))
.pipe(csv.stringify({ header: true, quoted: true }))
.pipe(outputCsv);
Gives the output I expect (output same as input, apart from the quotes) when the input has lines beyond the header, but gives an empty file instead when test_in.csv only contains a header. Is that expected? How can I force it to always dump the header to the output?
Many thanks in advance.
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 with the provided test_in.csv/test_out.csv stream pipeline, especially csv.parse({ columns: true }) and csv.stringify({ header: true, quoted: true }), using an input containing only the header. Check the existing parser and stringifier tests for header-only behavior; done means the expected header output is documented or covered by a confirmed fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100