From: Vimal Selvam Date: 2012-01-02T18:12:12+09:00 Subject: Re: Reading CSV File Hi Darren, The way you use the do block is not appropriate. Anyway, if I understood your problem properly, here you go: Read the CSV as like below which stores the whole content in an array of arrays: (Refer: http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html) arr_of_arrs = CSV.read("Sample.csv") print "Enter Product ID: " product_id = gets.chomp print "Enter Quantity: " quantity = gets.chomp puts arr_of_arrs[1..-1].each do |data| if data[0] == product_id puts "Product ID \t : \t#{data[0]}" puts "Product Name \t : \t#{data[1]}" puts "Product Price \t : \t#{data[2]}" puts "Product Type \t : \t#{data[3]}" puts puts "Total Price ordered \t : \t#{data[2].to_i * quantity.to_i}" exit end end I hope this is your requirement. Still you can enhance this by handling worst scenarios (using recursion). Cheers, - Vimal -- Posted via http://www.ruby-forum.com/.