Brian Candler wrote in post #1062462:
> steven gre wrote in post #1062429:
>
>> trying to send all the data scraped to csv file
>> business name, address, phone
>> i either get all 1 record 1 row or just phone #'s and sometimes nothing
>> been messing with this for some time, i'm a neub so this is probably
>> most of the problem
>>
>> trying to make it each record row bname,addy,phone
>
> This code:
>
> FasterCSV.open("test.csv", "w") do |csv|
>    csv << [bname,phone]
>
> end
>
> opens the file for write, truncates it to zero size if it already
> exists, and then writes one row consisting of two fields, bname and
> phone.
>
> If you want to write three fields, hopefully the solution is clear.
>
> If you want to write multiple rows, then you either open the file for
> append ("a") instead of write ("w"), or you open the csv file outside of
> a loop which iterates over the data you want to generate.
>
>  If you are getting blank fields, then check the source data:
>
>     puts "bname=#{bname.inspect}"
>     puts "phone=#{phone.inspect}"
>
> I suspect you will find that one of these is nil or empty string, in
> which case the problem is in parsing the data, not in writing it out to
> the CSV. (Sorry I'm not a Nokogiri user so I can't give you any hints on
> that part)

Brian i checked and i'm pulling data and i gave some though about you 
said opening the csv outside the loop... i'm a little lost as to how to 
do that i'm playing with mostly sample code and changing as needed i 
tried with an "a" but still getting the same results prints all the 
business names and then on next line all phone #'s on the next tried 
bname,phone and it's all on 1 row business names and then phones "bname 
bname bname phone phone phone....

-- 
Posted via http://www.ruby-forum.com/.