On Jan 26, 2012, at 8:18 PM, Bala TS wrote:

> I am using csv...
> 
> it is work:
> 
> if you are interested try this way:
> 
> require 'csv'
> 
> reader = CSV.open("file_location", "r")
> reader.shift # this line is used to skipped first header line
> reader.each{|row|
> first_field = row[0]
> second_field = row[1]
> 
> Module_Name.create(
>  :attribute1 => first_field,
>  :attribute2 => second_field
>  )
> }

I don't know if CSV has the option, but FasterCSV has an option you can pass to 
inform it that the first line is the header row and it will skip it 
automatically...

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to