From: Bosko Ivanisevic Date: 2009-02-17T04:40:09+09:00 Subject: Re: Parsing CSV file into a database On Feb 16, 5:39 pm, Nick Hoyle wrote: > Ok great! will do > > Nick > > > > James Gray wrote: > > On Feb 16, 2009, at 9:57 AM, Nick Hoyle wrote: > > >> ok thanks thats great, thanks for the quick response. Have you any > >> sample code or examples that you could possible provide me? > > > It's probably as simple as: > > >    require "open-uri" > >    require "rubygems" > >    require "faster_csv" > >    open("url goes here") do |csv| > >      FCSV.new(csv).each do |row| > >        # load row into database here... > >      end > >    end > > > Give it a shot and come back with specific questions when you get stuck. > > > James Edward Gray II > > -- > Posted viahttp://www.ruby-forum.com/. Here is a sample for downloading historical data from Yahoo: def get_historical_data(symbol, startDateString, endDateString) startDate = Date.parse(startDateString) endDate = Date.parse(endDateString) query = "/table.csv?s=#{symbol}&g=d" + "&a=#{startDate.month-1}&b=#{startDate.mday}&c=# {startDate.year}" + "&d=#{endDate.month-1}&e=#{endDate.mday}&f=# {endDate.year.to_s}" Net::HTTP.start("itable.finance.yahoo.com", 80) { |http| res = http.get(query) res.body } end