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
?
其次,我使用if
语句是获取特定行的最佳方式吗?我可以将整个 CSV 加载到某种临时表中,然后获取我需要的东西吗?