When using the fs reading mechanism with pipes, an error is thrown in strict mode if one of the rows does not match the length of the header. However, a try-catch block around the entire chain won't catch the error. Here's an example:
try {
fs.createReadStream(file_path)
.pipe(csv({
separator: ",",
strict: true
}))
.on('headers', function (headers) {
console.log("headers: ", headers)
})
.on('data', function (data) {
// a row was parsed
results.push(data)
})
.on('end', function () {
//
console.log(results);
});
} catch (err) {
// error parsing csv - it never gets here
}
When using the fs reading mechanism with pipes, an error is thrown in strict mode if one of the rows does not match the length of the header. However, a try-catch block around the entire chain won't catch the error. Here's an example: