Array of arrays to file

i want to use faster csv to write a array of arrays to file. But i am
little stuck on how do do it.
require ‘fastercsv’
arr=[[1,2],[2,3]]
arr.each { row|
FasterCSV.open(“c:\temp\one.csv”, “w”)
do |csv|

csv<<row
end
}
end

So, what happened when you ran your script? What did it do?

I reckon you have it inside-out, because you’re re-opening the CSV file
for each row of the array, which will erase the file.

I think you should open the CSV file once, and then write each row.

require ‘rubygems’
require ‘fastercsv’
arr=[[1,2],[2,3]]
FasterCSV.open(“temp.csv”, “w”) do |csv|
arr.each do |row|
csv << row
end
end

On Oct 24, 12:40am, Brian C. [email protected] wrote:

FasterCSV.open(“temp.csv”, “w”) do |csv|
arr.each do |row|
csv << row
end
end


Posted viahttp://www.ruby-forum.com/.

you are right. thanks.