From: steven gre Date: 2012-05-29T04:21:14+09:00 Subject: faster CSV writing trying to take scraped info business name address and phone# i can get the values into a variable but it writes to 1 line in csv i,m not concerned with headers but do want to write columns corectly. I'm new to butchering ruby but really like all the functions I've found/used so far. here is the code i'm working with require 'rubygems' require 'fastercsv' require 'nokogiri' require 'open-uri' page = Nokogiri::HTML(open("http://www.yellowpages.com/florida/auto-repair?q=auto+repair")) bname = page.css("h3.business-name.fn.has-menu.org").text addy = page.css("span.street-address").text csz = page.css("span.city-state").text count = page.css("p.result-count").text count = count.gsub(/Results 1-30 of /,'') phone = Array.new phone = page.css("span.business-phone.phone").text phone= phone.gsub(/\n/,'') phone= phone.gsub(/ /,'') phone= phone.gsub(/\(/,' ') phone= phone.gsub(/\)/,'-') puts phone # Writing data into a csv file FasterCSV.open("test.csv", "w") do |csv| csv << [bname,phone] end -- Posted via http://www.ruby-forum.com/.