M
Michael Guterl
Anyone have any suggestions on pushing a flat CSV file into a
relational db? I am currently thinking of a solution working with
FasterCSV and ActiveRecord. I picture something like the following,
although I'm sure someone can make a better suggestion...
FasterCSV.read("data.csv", :headers => true).each do |row|
Product.create(
:name => row["Product Name"],
:category => Category.find_or_create_by_name(row["Product Category"]),
:shipping_category =>
ShippingCategory.find_or_create_by_weight(row["Weight"]),
:color => row["Product Color"],
:description => row["Product Description"]
)
end
My Product.create method call is HUGE, it keeps going and going...
Any suggestions?
TIA,
Michael Guterl
relational db? I am currently thinking of a solution working with
FasterCSV and ActiveRecord. I picture something like the following,
although I'm sure someone can make a better suggestion...
FasterCSV.read("data.csv", :headers => true).each do |row|
Product.create(
:name => row["Product Name"],
:category => Category.find_or_create_by_name(row["Product Category"]),
:shipping_category =>
ShippingCategory.find_or_create_by_weight(row["Weight"]),
:color => row["Product Color"],
:description => row["Product Description"]
)
end
My Product.create method call is HUGE, it keeps going and going...
Any suggestions?
TIA,
Michael Guterl