3
require 'csv'
CSV.foreach(filename, :headers => true) do |row|
if column3 = true || column 4 = true
Model.create!(row.to_hash)
else
skip
end
end
首先,有沒有辦法在row.to_hash
期間只抓取某些列?從導入CSV的特定行和列
二,是我使用if
聲明抓取特定行的最佳方式嗎? 我可以將整個CSV加載到某種排序表,然後抓住我需要的東西嗎?
你對我很好,jvnill。謝謝! – Dudo 2013-02-24 04:20:29