Skip to content

Instantly share code, notes, and snippets.

@feoh
Last active January 2, 2016 15:58
Show Gist options
  • Save feoh/8326708 to your computer and use it in GitHub Desktop.
Save feoh/8326708 to your computer and use it in GitHub Desktop.
Wrote a 5M script to print a list of my twitter followers and tweet counts, sorted by tweet count ascending.
#!/usr/bin/env ruby
#
# This little ditty will print a list of who you follow, ranked
# by tweet count. I used the awesome t gem ( https://github.com/sferik/t )
# to generate the raw data like so: t timeline --csv | tee tweets.csv
require 'csv'
tweet_count = Hash.new(0)
CSV.foreach("tweets.csv") do |tweet|
# format: 421057153240408064,2014-01-08 23:13:42 +0000,zoebread,WWJW what would jesus wear
# Twitter ID = column 2.
tweeter = tweet[2]
tweet_count[tweeter] += 1
end
sorted_count = tweet_count.sort_by {|_key, value| value}
sorted_count.each do |t|
puts "Twitter ID: #{t[0]} | Tweet Count: #{t[1]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment