Created
April 14, 2012 17:57
-
-
Save sllvn/2386369 to your computer and use it in GitHub Desktop.
Verite Spotify contest vote tallier
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
#!/usr/bin/env ruby | |
# CSV file available at: http://dl.dropbox.com/u/24209319/Verite%20Spotify%20Playlist%20Voting-%20Foreign%20Languages.csv | |
require 'csv' | |
class Tally < Hash | |
def vote(key, x) | |
self[key] = 0 unless self[key] | |
self[key] += x | |
end | |
end | |
tally = Tally.new | |
CSV.foreach("Verite Spotify Playlist Voting- Foreign Languages.csv") do |row| | |
next if row[2] == "First song choice" # ignore first line of file | |
tally.vote(row[2], 3) | |
tally.vote(row[3], 2) | |
tally.vote(row[4], 1) | |
end | |
tally.sort_by { |key,value| value }.reverse.each do |t| | |
puts t | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment