From: Zoltar Speaks Date: 2007-11-02T23:06:31+09:00 Subject: CSV with Ruby Newbie Hey guys. I am currently following an example in: "Programming Ruby: The Pragmatic Programmers Guide" (pg. 663) on reading CSV files with Ruby. I am struggling though to get the code to read a CSV file that has a header in it. I have copied the example exactly but get the following error: undefined method `process' for main:Object (NoMethodError) from /usr/local/lib/ruby/1.8/csv.rb:560:in `each' from solution.rb:4 My Code: require 'csv' reader = CSV.open("csvfile", "r") header = reader.shift reader.each{|row| process(header, row)} CSV.open("csvfile", "r") do |row| qty = row[0].to_i price = row[2].to_f printf "%20s: $%5.2f %s\n", row[1], qty*price, row[3] || " ---" end (If your looking in the book then i have just adapted the csvfile to be the same as csvfile_hdr) Would really appreciate it if someone could perhaps point out what i am doing wrong please. Thanks -- Posted via http://www.ruby-forum.com/.