Ruby CSV manipulation

Read

file = CSV.open('path/to/file.csv', col_sep: ',')
file.each do |line|
  pp line
end

Write

header  = ['A', 'B', 'C']
content = [[1, 2, 3], [4, 5, 6]]

csv = CSV.generate do |output|
  output << header

  content.each do |item|
    output << item
  end
end

File.write('result.csv', csv)