Skip to content

Instantly share code, notes, and snippets.

@energee
Forked from mcampa/cabana_fingerprint.js
Last active December 7, 2017 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save energee/29f9de9539ee03d937401925291bcf84 to your computer and use it in GitHub Desktop.
Save energee/29f9de9539ee03d937401925291bcf84 to your computer and use it in GitHub Desktop.
cabana_fingerprint.js
const fs = require('fs');
const content = fs.readFileSync('./data.csv', 'utf8');
const data = content.trim()
.split('\n')
.filter(l => l)
.map(l => l.split(','))
.map(row => ({ time: row[0], id: `${row[2]}:${row[1]}`, message: row[3] }))
const ids = {};
data.forEach(row => {
let length = row.message.replace(/^0+/, '').length;
if (length % 2 === 1) {
length++;
}
if (!ids[row.id]) {
ids[row.id] = 0;
}
if (length > ids[row.id]) {
ids[row.id] = length / 2;
}
});
console.log(ids);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment