0

So I having problems with my csv-parser that is reading values where it adds a column on empty cells from a csv file. It gives an error of

column header mismatch expected: 17 columns got: 18

For now I have to go in the csv file and backspace a comma to match the columns. I know is a parse csv issue, has anyone encounter this? below is my csv code.

function  readStream () {
          let stream  = fs.createReadStream("accounts.csv");

          fast
              .fromStream(stream, {
                headers: true
              })
              .on("data" , fetchYelp, fetchWhitePages, fetchGooglePlace, writeStream
              )
              .on("end", function () {

                console.log("Done Reading");
              });
      }

readStream();

1 Answer 1

1

Could you try using the discardUnmappedColumns option, e.g. ? That works for me!

function  readStream () {
    let stream  = fs.createReadStream("accounts.csv");

    fast
        .fromStream(stream, {
          headers: true,
          discardUnmappedColumns: true
        })
        .on("data" , fetchYelp, fetchWhitePages, fetchGooglePlace, writeStream ) {
        })
        .on("end", function () {

        console.log("Done Reading");
        });
}

readStream();
Sign up to request clarification or add additional context in comments.

2 Comments

what does the below function do? function(d){ console.log(d); {
Oh sorry, that's just dumping out the rows, just replace with your original callback!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.