-
-
Save energee/29f9de9539ee03d937401925291bcf84 to your computer and use it in GitHub Desktop.
cabana_fingerprint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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