Created
February 29, 2016 14:02
-
-
Save desflynn/044de57b9b54a6347bb8 to your computer and use it in GitHub Desktop.
Parse twitter user handles from a local stream of tweets
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
var fs = require('fs') | |
var _ = require('underscore') | |
var results = []; | |
fs.readFile('results.txt', function(err,data) | |
{ | |
var data = JSON.parse(data); | |
data.forEach(function(entry) | |
{ | |
results.push(entry.userScreenName) | |
}); | |
var uniqueResults = _.uniq(results, function(x){ | |
return x; | |
}); | |
console.log("Found / Unique: " + results.length + ' / ' + uniqueResults.length) | |
var file = fs.createWriteStream('ids.txt'); | |
file.on('error', function(err) { /* error handling */ }); | |
uniqueResults.forEach(function(v) { | |
file.write(v + '\r\n'); | |
}); | |
file.end(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment