Friday 2 June 2017

Detect csv delimiter and newline in nodeJS

Prior to parsing the csv file, I'm checking its delimiter and newline. I use "detect-csv" package:

var detect = require('detect-csv');
var csv = detect(inputFile);
console.log(csv.delimiter);
console.log(csv.newline);

I have predefined arrays of delimiters and newline endings in config file and check if they contain csv.delimiter and csv.newline. If contain, parse file and if not, return error. Everything is ok except this package doesn't support multiple characters, e.g. \r\n. Is there any solution to support \r\n ?



via basic

No comments:

Post a Comment