Skip to content

Instantly share code, notes, and snippets.

@desflynn
Created February 29, 2016 14:02
Show Gist options
  • Save desflynn/044de57b9b54a6347bb8 to your computer and use it in GitHub Desktop.
Save desflynn/044de57b9b54a6347bb8 to your computer and use it in GitHub Desktop.
Parse twitter user handles from a local stream of tweets
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