How to write columns header to a csv file with Ruby?
I would recommend to use the CSV-library instead: require ‘csv’ CSV.open(‘test.csv’,’w’, :write_headers=> true, :headers => [“numerator”,”denominator”,”calculation”] #< column header ) do|hdr| 1.upto(12){|numerator| 1.upto(12){ |denominator| data_out = [numerator, denominator, numerator/denominator.to_f] hdr << data_out } } end If you can’t use the w option and you really need the a+ (e.g., the data isn’t available all at … Read more