On Feb 16, 2011, at 1:43 AM, Chris Kottom wrote:

> Simple example...
>=20
> require "csv"                              # require the CSV library
> CSV.foreach("path/to/file.csv") do |row|   # open your file and loop =
through
> the rows
>  p row                                    # print each row's contents
>  p row.count                              # count the number of values =
in
> each row (CSV::Row is Enumerable)
>  ...
> end

Taking that one step further, an import using Rails 3 usually goes =
something like this:

  require "csv"
  CSV.new( params[:file].tempfile,
           :headers           =3D> true,
           :header_converters =3D> :symbol ).each do |row|
    MyModel.create!(row.to_hash)
  end

Hope that helps.

James Edward Gray II=