[Rails] Re: Skipping the First Line when reading in a text file
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
)
}
Bye:)
bdeveloper01
--
Posted via http://www.ruby-forum.com/.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home