Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] Why does csv-parser skips headers with empty data? #181

Open
abhishekdeshkar opened this issue Sep 26, 2020 · 1 comment
Open

[HELP] Why does csv-parser skips headers with empty data? #181

abhishekdeshkar opened this issue Sep 26, 2020 · 1 comment

Comments

@abhishekdeshkar
Copy link

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);

});
@SimonSimCity
Copy link
Contributor

SimonSimCity commented Sep 30, 2020

Which version of this library are you using? Can you please share a sample of a csv file?

Maybe it is related to #151 which was introduced after 2.3.0 (the last version where the case described in #151 worked as expected).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants