Advertisement
dereksir

Untitled

Jun 11th, 2024 (edited)
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.26 KB | None | 0 0
  1. # open the CSV file in write mode and add headers
  2. CSV.open('products.csv', 'w', headers: true) do |csv|
  3.   # write headers to the CSV file
  4.   csv << ['Product Name', 'Price']
  5.   product_data.each do |product|
  6.     csv << [product[:name], product[:price]]
  7.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement