mafintosh / mafintosh/csv-parser
[HELP] Why does csv-parser skips headers with empty data?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.5k
- Forks
- 143
- PR merge metrics
- No merged PRs in 30d
Description
I have a CSV file which I'm reading it row wise. There are some rows which are empty but columns do exists.
The issue is that it doesn't read header name which has no data.
How do I read everything ?
```
function GetRows(headers)
{
StoreHeaders = headers;
StoreHeaders.forEach(header => {
let WordsArray = [];
let CurrentGroupName;
fs.createReadStream('word_groups.csv')
.pipe(csv())
.on('data', (data) => {
if(data[header])
{
WordsArray.push(data[header]);
CurrentGroupName = header;
}
})
.on('end', () => {
console.log(CurrentGroupName);
});
});
}
fs.createReadStream('word_groups.csv')
.pipe(csv())
.on('headers', (headers) => {
GetRows(headers);
});
```
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
Reproduce the behavior with word_groups.csv using the csv() stream and its headers/data events. Inspect how the parser represents columns with empty values, and compare that with the data[header] condition in the example. Done means establishing whether this is parser behavior or a usage issue and recording the expected handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100