Skip to content

Instantly share code, notes, and snippets.

@domitry
Created March 4, 2015 15:50
Show Gist options
  • Save domitry/a3e59ce432847353be91 to your computer and use it in GitHub Desktop.
Save domitry/a3e59ce432847353be91 to your computer and use it in GitHub Desktop.
じーぴーえー (阪大koanフォーマット)
# -*- encoding: utf-8 -*-
require "csv"
path = ARGV[0]
csv = CSV.read(path, headers: true, encoding: "Shift_JIS:UTF-8")
column = csv["評語"]
column.delete("欠席")
sum = column.reduce(0) do |memo, alphabet|
val = {
"\uFF33" => 4,
"\uFF21" => 3,
"\uFF22" => 2,
"\uFf23" => 1
}[alphabet]
raise "Invaild val: " + alphabet.to_s if val.nil?
memo + val
end
puts "Your GPA:" + (sum.to_f / column.length).to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment