Tulis CSV dengan header ruby

headers = ['col1','col2','col3']

CSV.open(file_path, 'a+', {force_quotes: true}) do |csv|
  csv << headers if csv.count.eql? 0 # csv.count method gives number of lines in file if zero insert headers
end
Terrible Tapir