Skip to content

Instantly share code, notes, and snippets.

@irisfofs
Created August 31, 2015 19:18
Show Gist options
  • Save irisfofs/8ef25ea599489c491f47 to your computer and use it in GitHub Desktop.
Save irisfofs/8ef25ea599489c491f47 to your computer and use it in GitHub Desktop.
Short script to compute histogram totals for check-in times.
require 'csv'
prereg = CSV.read("boomset_prereg_attendance_report_35918_08312015180554.csv")
at_door = CSV.read("boomset_at_door_attendance_report_35998_08312015180637.csv")
# puts prereg[0]
# Remove first row
prereg.shift
at_door.shift
TIME_FORMAT = "%m/%d/%Y %H:%M:%S (1)"
@out_times = []
@out_hist = Hash.new(0)
def count_check_in(line)
times = line[23]
unless times.nil?
first_check_in = DateTime.strptime(times.split(", ")[1], TIME_FORMAT)
@out_times << first_check_in
day_and_hour = first_check_in.strftime("%F %H")
@out_hist[day_and_hour] = @out_hist[day_and_hour]+1
end
end
prereg.each { |line|
count_check_in(line)
}
at_door.each { |line|
count_check_in(line)
}
puts "Time\t\tCheck-Ins"
@out_hist.keys.sort.each { |key|
puts "#{key}\t#{@out_hist[key]}"
}
# File.open("output.csv", "w") { |f|
# f.write(out_times.map { |dt| dt.strftime("%F %T") }.join("\n"))
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment