I have a hadoop file that has \u001 as a delimiter, and I try to read the data and split records by \u001. But the length is always 1, that is the data is not been spilt.
var fs = require('fs');
var buffer = fs.readFile('20140820075209.txt', function (err, data) {
console.log(data.toString());
console.log(data.toString().split('\\u001').length);
});
You shouldn't escape the backslash if you want the actual character:
console.log(data.toString().split('\u0001').length);
or:
console.log(data.toString().split('\x01').length);