My CSV file (obyek.csv) is look like:
"title","description","latitude","longitude"
And my table structure is:
create_tablebyeks do |t| t.column :title, :string, :limit => 40 t.column :description, :text t.column :latitude, :decimal, :precision => 20, :scale => 17 t.column :longitude, :decimal, :precision => 20, :scale => 17 t.column :created_at, :datetime t.column :updated_at, :datetime t.column :created_by, :integer t.column :updated_by, :integer end
From my rails directory
$ ruby script/console
>>require 'csv'
>>o = CSV.readlines('obyek.csv')
>>i = 0
>>while (i < o.length)
>>Obyek.create(:title => o[i][0], :description => o[i][1], :latitude => o[i][2], :longitude => o[i][3])
>>i += 1
>>end



