Or, maybe you could use some CSV reader library to looping through the CSV contents like this?
const fs = require('fs');
const csv = require('csv-parser');
fs.createReadStream('test.csv')
.pipe(csv())
.on('data', (row) => {
console.log(row['Modem ID'], row['Total Chargeable'].replace(',', '.'));
})
.on('end', () => {
console.log('CSV file successfully processed');
});
I think this approach would be better, rather that you read the CSV as a string