foreach(path, options = Hash.new, &block)public
The options parameter can be anything CSV::new() understands. This method also understands an additional :encoding parameter that you can use to specify the Encoding of the data in the file to be read. You must provide this unless your data is in Encoding::default_external(). CSV will use this to determine how to parse the data. You may provide a second Encoding to have the data transcoded as it is read. For example, encoding: "UTF-32BE:UTF-8" would read UTF-32BE data from the file but transcode it to UTF-8 before CSV parses it.
# File lib/csv.rb, line 1205 def self.foreach(path, options = Hash.new, &block) open(path, options) do |csv| csv.each(&block) end end