Created
January 18, 2013 07:19
-
-
Save rounak/4562912 to your computer and use it in GitHub Desktop.
Script writes to STDOUT the Twitter clients you've used along with the number of tweets. Save the output as something.csv and open in Excel/Numbers to do interesting things like making charts etc.
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
#redirect stdout to something.csv and open it in Numbers/Excel to do whatever you want | |
require 'csv' | |
#total_tweets = 0 | |
client_hash = {} | |
dir_name = "~/path/to/tweetsfolder/" + "data/csv/" #insert path to tweets folder | |
file_paths_array = Dir.entries(dir_name) | |
file_paths_array.delete_at(0) | |
file_paths_array.delete_at(0) | |
file_paths_array.each do |file_path| | |
arr_of_arrs = CSV.read(dir_name+file_path) | |
arr_of_arrs.delete_at(0) | |
arr_of_arrs.each do |arr| | |
client_name = arr[6].gsub(%r{<[^>]*>},"") | |
#total_tweets = total_tweets+1 | |
client_hash[client_name] = client_hash[client_name].to_i() + 1 | |
end | |
end | |
#puts total_tweets | |
client_hash.each do |key,value| | |
puts key + "," + value.to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment