CSV:
TableName, RowCount, TableStatus
table1, 10, Y
table2, 21, N
table3, 23, Y
table4, 24, N
table5, 25, Y
Need to convert CSV to JSON in this format:
{
"table1": {
"row_count": "10"
}
},
{
"table3": {
"row_count": "23"
}
},
{
"table5": {
"row_count": "25"
}
}
const csvFilePath='sample.csv'
const csv=require('csvtojson')
csv()
.fromFile(csvFilePath)
.then((jsonObj)=>{
console.log(jsonObj);
})
- I am using Node csvtojson NPM
- I am able to convert to JSON, but I need the json in the above format out of the box. Is it possible?
- And also If "TableStatus" value is "N", it should not add that row in JSON.
Note: I am able to convert to desirable JSON format by iterating the JSON object, but is there any way to convert using this NPM.
Thanks.