Use the library, CSV has many errors. I came to enjoy the package csv
. It is here: https://www.npmjs.com/package/csv . Here is a very quick example using async api.
const fs = require('fs')
var parse = require('csv-parse')
fs.readFile(inputPath, function (err, fileData) {
parse(fileData, {columns: false, trim: true}, function(err, rows) {
})
})
, , CSV. , String.prototype.split()
?
const fs = require('fs')
fs.readFile(inputPath, 'utf8', function (err, data) {
var dataArray = data.split(/\r?\n/);
})