Created
August 6, 2014 02:35
-
-
Save kaityo256/d3b04c0421a35ac0691d to your computer and use it in GitHub Desktop.
This file contains 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
# -*- encoding: utf-8 -*- | |
require "rexml/document" | |
doc = nil | |
filename = ARGV[0] | |
if ARGV.size == 0 | |
puts "usage: ruby kaken.rb filename" | |
exit | |
end | |
File.open(filename) {|fp| | |
doc = REXML::Document.new fp | |
} | |
h = Hash.new | |
h.default = 0 | |
i = 0 | |
doc.root.elements.each {|e| | |
d = REXML::XPath.first(e,"date") | |
next if d == nil | |
f = REXML::XPath.first(d,"from") | |
next if f == nil | |
year = f.text.to_i | |
h[year] = h[year] + 1 | |
} | |
h.to_a.sort{|a,b| (a[0] <=> b[0])}.each{|a| | |
puts "#{a[0]} #{a[1]}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment