Answers for "rails write to csv"

0

ruby write to csv

# To a file
CSV.open("path/to/file.csv", "wb") do |csv|
  csv << ["row", "of", "CSV", "data"]
  csv << ["another", "row"]
  # ...
end

# To a String
csv_string = CSV.generate do |csv|
  csv << ["row", "of", "CSV", "data"]
  csv << ["another", "row"]
  # ...
end
Posted by: Guest on May-19-2021
0

save to csv ruby

CSV.open("filename.csv", "wb") do |row|
  row << ["a", "b", "c"]
end
Posted by: Guest on January-07-2021
0

how to write CSV file in rails

require 'csv'
file = "my_file.csv"
CSV.open( file, 'w' ) do |writer|
  @coun.each do |c|
    writer << [c.name, c.country_code, c.user_id, c.subscriber_id]
  end
end
Posted by: Guest on November-12-2021

Browse Popular Code Answers by Language