This code works fine....

require "rubygems"
require "csv"

CSV.open("/home/user1/sample.csv", "r", :headers => true) do |csv|
  puts "got all contents from file #{csv}"
  # not iterate each row
  csv.each do |row|
    puts "Each row #{row}"
  end
end

try this...if not let me know your ruby version and OS details...

-- 
Posted via http://www.ruby-forum.com/.