Thanks for the comments. I am working on your suggestions.
I figured out that there were repeating lines in the customers.txt that
was the reason why some of the lines were duplicated in the result as
well. So, just modified the customers.txt file read like this:
lastline =""
f2 = File.open("customers.txt", 'r').each {|line|
# read every line into string
str = line.chomp!
if str != nil
str.length
cuname = str[3, 21]
custo = str[27,6]
if lastline != cuname
q = Query.new
q.cuname = cuname
q.custo = custo
arr2.push(q)
end
lastline =cuname
end
}
Now, it is fine. But, more and more I am working on this code, my
feeling is that I started in a very wrong direction and made my life and
the code too complicated.
Thank you again!
--
Posted via http://www.ruby-forum.com/.