Created
October 10, 2023 21:17
-
-
Save 7rebux/67fb804b3cf9db2a86349186ea64d118 to your computer and use it in GitHub Desktop.
Ubisoft Playtime Calculator
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
import fs from 'fs'; | |
const content = fs.readFileSync("./uplay_traffic_data.csv").toString(); | |
const lines = content.split("\n").slice(1); | |
const playTimes = {} | |
for (const line of lines) { | |
const [ | |
_accountId, | |
game, | |
_platform, | |
_packageDesc, | |
_purposeDesc, | |
_contentDesc, | |
_actionDesc, | |
_actionDate, | |
_countryDesc, | |
sessionTime | |
] = line.split(","); | |
const secondsRegex = /(\d+)sec/.exec(sessionTime) | |
// Skip "Session launched" entries | |
if (secondsRegex === null) continue | |
playTimes[game] = (playTimes[game] ?? 0) + parseInt(secondsRegex[1]) | |
} | |
console.log(playTimes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment