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
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
--
Posted via http://www.ruby-forum.com/.
you are right. thanks.
On Oct 24, 12:40 am, Brian Candler <b.cand...@pobox.com> wrote:
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--
Posted viahttp://www.ruby-forum.com/.