I am creating a simple app in Ruby on Rails. Need to import data from cvs files at finance.google.com (an example http://www.google.com/finance/historical?q=NYSE:SMH). The program then stores this data for all 500 companies of S&P500 on a daily basis into a database. What's the proper way to do this?
Simplest way could be this, it's almost just like 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: that was the approach from a script. For a Rails approach you could write a Rake task to do this, and run it periodically via a scheduled task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With