convert array of hashes to csv file
Try this: CSV.open(“data.csv”, “wb”) do |csv| @data.each do |hash| csv << hash.values end end If you want the first line of the CSV to contain the keys of the hash (a header row), simply do: CSV.open(“data.csv”, “wb”) do |csv| csv << @data.first.keys # adds the attributes name on the first line @data.each do |hash| csv … Read more