Docstoc

CSV

Document Sample
CSV Powered By Docstoc
					CSV
              output to CSV
def gen_csv
 require "csv"
 CSV.open('public/csvfile.csv', 'w') do |writer|
  writer << ['year 50', 100]
  writer << ['year 51', 120]
  writer << ['year 52', 200]
 end
 render :text => "ok"
end
            Input from CSV
def do_csv
 require "csv"
 t=0
 CSV.open('csvfile.csv', 'r') do |row|
  t += row[1].to_i
 end
 render :text => t
end

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:6
posted:12/1/2011
language:English
pages:4