Resultant JSON in lowercase if csv file has only two rows and convert header to lowercase
If I have a csv file with two rows like this: Name,AGE John,23
When use:
csvToJson({trim:true})
.fromFile(filePath)
.preFileLine((fileLine,idx)=>{
//Convert csv header row to lowercase before parse csv file to json
if (idx === 0 ){return fileLine.toLowerCase()}
return fileLine;
})
.then(jsonObj => {
console.log(jsonObj)
}
print
[{name:john,age:23}]
everything in lowercase, but what I want is only the keys in lower case, not the values in the resultant JSON.
This only apend when the file has two rows (header row and another). If the file have three or more rows like this:
name,age
John,23
Amelia,20
The result is correct [{name:John,age:23},{name:Amelia,age:20}]
Duplicate of #351 Both seem to occur because the counter isn't incremented correctly for the last line
Bump!