Last active
January 30, 2019 12:34
-
-
Save nickstamas/715e3da4f57cbacd7143d735ab5dece4 to your computer and use it in GitHub Desktop.
Parsing JSON lines data for https://overinstagram.com
This file contains hidden or 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
| var lineReader = require('readline').createInterface({ | |
| input: require('fs').createReadStream('./focussion-filtered-2.jl') | |
| }); | |
| var results = {}; | |
| lineReader.on('line', function (line) { | |
| var json = JSON.parse(line); | |
| try { | |
| if (json["username"] && json["username"][0] === "/ViewsOfParadise") { | |
| var feedbackCount = json["feedback-count"]; | |
| var regexp = /([0-9]+\s[a-z]+\s[0-9]+)/; | |
| var postMeta = json["post-meta"]; | |
| var date = regexp.exec(postMeta)[0]; | |
| results[date] = results[date] ? results[date] + 1 : 1; | |
| } | |
| } catch(err) { | |
| console.log(err); | |
| } | |
| }); | |
| lineReader.on('close', function() { | |
| Object.keys(results).forEach(function(key) { | |
| require('fs').appendFileSync('./focussion-seanAllenTimeline.csv', '"' + key + '"' + ',"' + results[key] + '"\n'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment