Ruby on Rails - import data from a csv file from a URL

I am creating a simple application in Ruby on Rails. You need to import data from cvs files to finance.google.com (example http://www.google.com/finance/historical?q=NYSE:SMH ). The program then stores this data for all 500 S & P500 companies daily in a database. What is the right way to do this?

+4
source share
2 answers

The simplest way could be this, it is almost the same as reading a file:

require "open-uri" url = "http://www.google.com/finance/historical?q=NYSE:SMH" url_data = open(url).read() # favorite way of parsing csv goes here 

EDIT: it was an approach from a script. For the Rails approach, you can write a Rake task for this and run it periodically using a scheduled task.

+13
source

Please check this meaning by making sure it solves your problem https://gist.github.com/victorhazbun87/9ac786961bbf7c235f76

0
source

All Articles