Skip to navigation
How to load in a CSV file with ruby 1.9 and process it?
07.12.13
Reply
Anonymous
example with rails: 1 once the csv file is saved you can load it with a ruby function. 2 find the record in the database and update it with the data from the csv require 'csv' CSV.foreach("#{RAILS_ROOT}/public/csv/lastprices.csv") do |key,value| if key if @product = Product.find(:first, :conditions => [ "title = ?", key.downcase]) @product.price = round_prices((value.to_f*100).round) @product.save end end end
07.12.13
Reply
Anonymous
Information Epoch 1732466264
Design programs to be connected to other programs.
Home
Notebook
Contact us