Created
September 24, 2009 17:03
-
-
Save luikore/192874 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
require 'iconv' | |
require 'rubygems' | |
require 'ipparse' | |
write_now = Time.now | |
counts = {} | |
comma = ',' | |
open "member22.csv" do |f| | |
loop do | |
f.gets comma | |
break if f.eof? | |
f.gets comma | |
ip = f.gets(comma).chop | |
if counts[ip] | |
counts[ip] += 1 | |
else | |
counts[ip] = 1 | |
end | |
end | |
end | |
open "countMember22.csv", 'w' do |f| | |
Iconv.open 'GBK', 'UTF-8' do |i| | |
counts.each {|k, v| f.puts "#{i.iconv IPParse.parse k} #{v}" } | |
end | |
end | |
puts Time.now - write_now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment