Skip to content

Instantly share code, notes, and snippets.

@ssov
Created February 21, 2014 03:02
Show Gist options
  • Save ssov/9128030 to your computer and use it in GitHub Desktop.
Save ssov/9128030 to your computer and use it in GitHub Desktop.
require 'stringio'
require 'csv'
str = StringIO.new(IO.read("SIKS*********.csv")).read.gsub(/\r/, '')
parse = CSV.parse(str)
parse.shift
sum = 0.0
a = 0.0
parse.each do |row|
if ["A+", "A", "B", "C"].member?(row[6])
sum += row[5].to_f
end
if ["A+", "A"].member?(row[6])
a += row[5].to_f
end
end
puts "#{a}/#{sum} = #{a/sum * 100.0}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment