Skip to content

Instantly share code, notes, and snippets.

@benbalter
Created August 29, 2013 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbalter/6382445 to your computer and use it in GitHub Desktop.
Save benbalter/6382445 to your computer and use it in GitHub Desktop.
Ruby script to parse Go To Webinar reports for actually usefully analytics
require 'csv'
require 'gman'
data = CSV.read("data.csv", {:headers => true, :return_headers => false, :header_converters => :symbol, :converters => :all} )
# attended
attended = data.select {|row| row[:attended] == "Yes" }
percent = 100 * attended.count / data.count
puts "Attended: #{attended.count} (#{percent}% of those registered)"
# govies
gov = attended.select {|row| Gman::is_government? row[:email] }
percent = 100 * gov.count / attended.count
puts "Govies Attended: #{gov.count} (#{percent}% of those attending)"
# time in session
times = 0
attended.each {|row| times += row[:in_session_duration_minutes_] unless row[:in_session_duration_minutes_].nil? }
times = times / attended.count
puts "Average time in session: #{times.round(0)} minutes"
# q's asked
qs = 0
attended.each {|row| qs += row[:questions_asked_by_attendee].scan("Q: ").count unless row[:questions_asked_by_attendee].nil? }
puts "# of Qs: #{qs}"
qs = qs.to_f / attended.count
puts "Average # of Qs per person: #{qs.round(2)}"
# domains
tlds = {}
slds = {}
attended.each do |row|
domain = Gman::get_domain row[:email]
sld = "#{domain.sld}.#{domain.tld}"
tlds[domain.tld] = 0 unless tlds.include? domain.tld
slds[sld] = 0 unless slds.include? sld
tlds[domain.tld] += 1
slds[sld] += 1
end
tlds = tlds.sort_by {|k,v| v}.reverse
slds = slds.sort_by {|k,v| v}.reverse
puts "Top TLDs:"
tlds.each { |tld, count| puts " #{tld}: #{count}" if count > 1 }
puts "Top SLDs:"
slds.each { |sld, count| puts " #{sld}: #{count}" if count > 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment