Parse comma-separated value data
Given a string of CSV data, transforms it into an array of objects (if header data is provided) or an array of arrays.
var CSV = require('machinepack-csv');
// Parse comma-separated value data
CSV.parseCsv({
csvData: '"1","2","3","4"\n"a","b","c","d"',
schema: '*',
hasHeaderRow: true,
}).exec({
// An unexpected error occurred.
error: function (err) {
},
// OK.
success: function () {
},
});
A string of CSV data.
'"1","2","3","4"\n"a","b","c","d"'
Expected schema of each parsed row
Indicates whether or not the data has a header row.
true
An unexpected error occurred.
'Invalid closing quote at line 1'
OK.