require 'readahl' ifn, jfn = ARGV dset = [] File.open(ifn, 'r') {|fp| for line in fp row = line.split(/\t/) dsn, size, filter = row[0,3] filter = Regexp.new(filter) size = size.to_i dset.push [dsn, size, filter] end } File.open(jfn, 'r') {|fp| for line in fp row = line.chomp.split(/\t/) ahl = row[0] + row[1] fdsn = nil for dsn, size, filter in dset next unless filter === ahl $stderr.puts "dup #{ahl} #{fdsn} -> #{dsn}" if fdsn fdsn = dsn end raise "#{ahl} not found" unless fdsn tt, cc, di, gr, re, ar, lv, ut, ac = row ut.sub!(/ \[h\]/, '') if /^(\d\d )+\[h\]$/ === ut ft = AHL.fcsttime(tt, cc) el = AHL.element(tt, cc) xrow = [tt, cc, fdsn, lv, ft, ut, ac, el] puts xrow.join("\t") end }