So I'm using fast-csv to get all the rows from a csv file. The file I'm using is in UTF-16 format and using a ucs2 readStream, I'm getting every record out of the file.
_csv.fromStream(stream, {headers: true, delimiter: '\t'})
.on("record", function(data) {
count ++;
console.log(data.Date);
var dataHash = hash(data);
if (!dict.hasOwnProperty(dataHash)) {
dict[dataHash] = 1;
} else {
dict[dataHash]++;
}
})
I'm taking each row and I'm hashing it into a "|" delimited string. However, the date is not ever coming back correction. If I console.log(data), the Date property is definitely there but I cannot access it with data.Date, data["Date"], and data.hasOwnProperty("Date"); doesn't work either. The object looks like:
{
'Date': '07/10/2014',
'[Value 1]': 'xxx',
'[Value 2]': 'xxx',
'[Value 3]': 'xxx',
'[Value 4]': 'xxx',
}
Has anyone seen this before and maybe know what I'm doing wrong?
The problem had to do with either leading or trailing garbage. I was able to use a trim property on the fast-csv parser to fix the issue.