#!/usr/bin/ruby db = {} for line in ARGF row = line.chomp.split(/,/) # #oaiId:,#oaiDate:,#source:,#recordDate:,#bbox:,#title:, next unless /^WIS-TOKYO-WWIS$/ === row[2] id = row.first.sub(/.*=(oai:hko\.gov\.hk\.VHHH\.)?/, '') id = id.to_i if /^\d+$/ === id bbox = row[4] db[bbox] = [] unless db[bbox] db[bbox].push id end for bbox in db.keys.sort ids = db[bbox] next if ids.size <= 2 puts "#{bbox} #{ids.sort.join(' ')}" end