chris
11/5/2007 6:05:00 PM
Hello,
sorry i'm a beginner with ruby and hanging on
a problem comparing two arrays?
Have anybody an advice what's wrong in my logic, beacuse printing of k
and row2["id"] like
p "#{k} = #{row2["id"]}" works!?
many thanks ,Christian
rows=0
ngs=Array.new
# some thousand id's
FCSV.foreach("#{path}#{part1}",:headers =>true ,:col_sep => "\t") do |
row|
ngs.push(row["id"])
end
# a lot of millions
FCSV.foreach("#{path}#{part2}",:headers =>true ,:col_sep => "\t") do |
row2|
ngs.each do |k|
if k == row2["id"]
p row2
end
end
end
mp_hash.rb:36: undefined local variable or method `found' for
main:Object (NameError)
from cmp_hash.rb:34:in `each'
from cmp_hash.rb:34
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
1429:in `each'
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
990:in `foreach'
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
1162:in `open'
from c:/ruby/lib/ruby/gems/1.8/gems/fastercsv-1.2.0/lib/faster_csv.rb:
989:in `foreach'
from cmp_hash.rb:33