我已經使用下面的架構創建Rails的數據庫:導入CSV文件到Rails sqlite3的數據庫
ActiveRecord::Schema.define(:version => 20090807141407) do
create_table "trunks", :force => true do |t|
t.integer "npa"
t.integer "nxxFrom"
t.integer "nxxTo"
t.string "trnk"
t.datetime "created_at"
t.datetime "updated_at"
end
end
在我的CSV文件,我只有前四列(NPA,nxxFrom,nxxTo和trnk)。
如何在導入CSV數據的同時更新最後兩列?
總是感謝
如果創建從CSV文件中的每一行ActiveRecord模型,並保存它,然後ActiveRecord的將填充created_at /的updated_at你。你在問如何在Ruby中進行CSV解析? – mikej 2009-08-07 14:30:50
對不起,我是一名新手。 CSV文件是來自服務器的原始數據。你是說我可以以某種方式將其轉換爲ActiveRecord模型?如果這是可能的,那將會很好 – b1gtuna 2009-08-07 14:34:53