node-csvtojson icon indicating copy to clipboard operation
node-csvtojson copied to clipboard

preFileLine line index is not incremented for the second line or row in CSV

Open Jagadeshkumar-code opened this issue 5 years ago • 1 comments

Hello,

I am using the following sample code to convert CSV to JSON. while iterating csv rows, first iteration the lineIdx value coming as 1 and second-iteration also lineIdx value coming as 1. actually preFileLine line index value is not incremented for the second line in CSV. but the third line incrementing by 1 and the value is 2.

Is it an npm module issue? How can I solve this problem?

Note: I am using "csvtojson": "^1.1.9", verions

csv().fromStream(request.get('http://localhost:3000/response'))
    .preFileLine((fileLineString, lineIdx) => {
            if (lineIdx === 1) {
                return fileLineString.replace(/ /g,'')
            }
        return fileLineString;
    })

Jagadeshkumar-code avatar Jan 29 '20 19:01 Jagadeshkumar-code

Same just ran into this. Good to know I was not crazy here.

randallmeeker avatar Jun 24 '21 01:06 randallmeeker