Created
February 10, 2015 19:29
-
-
Save adamlwalker/66daab19aff67104c183 to your computer and use it in GitHub Desktop.
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
| require 'csv' | |
| unique_count = {} | |
| total_count = {} | |
| CSV.foreach('Lead_Source_Report.csv', :headers => true) do |total| | |
| total_count[total[9]] ||= 0 | |
| total_count[total[9]] += 1 | |
| end | |
| CSV.foreach('Lead_Source_Report.csv', :headers => true) do |row| | |
| unique_count[row[9]] ||= 0 | |
| if row[7].include? 'Won' | |
| unique_count[row[9]] += 1 | |
| elsif row[7].include? 'Promised' | |
| unique_count[row[9]] += 1 | |
| elsif row[7].include? 'Qualified' | |
| unique_count[row[9]] += 1 | |
| end | |
| end | |
| unique_count.each do |val,count| | |
| if count > 0 | |
| total = total_count[val] | |
| rate = count .to_f / total.to_f * 100 | |
| rate = rate.round | |
| puts "#{val} appears #{total} time(s) and was successful #{count} times in this cycle. #{rate}% success rate" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment