#!/usr/local/bin/ruby # -*- coding: utf-8 -*- require 'sqlite3' require 'kconv' dbfile = "vote.sq3" team = Hash.new votetbl = "vote.tbl" IO.foreach(votetbl) do |x| x = x.toeuc sname, gname = x.scan(/([-0-9a-z]+)\s+(.*)/i)[0] next unless sname && gname team[sname] = gname end mydir=File.expand_path(File.dirname($0)) table=(ARGV[0]||File.basename(mydir)) point = Hash.new(0) if test(?s, dbfile) db = SQLite3::Database.new("vote.sq3") db.transaction do db.execute("select team,sum(point) from #{table} group by team;") do |row| point[row[0]] = row[1].to_i end #db.results_as_hash = true #p db.execute("select team,sum(point) from #{table} group by team;") end end puts '
" printf("%s (%3d) | \n", team[t], t, point[t]) pt = point[t] print "\n "
printf '![]() |