Working with CSV

Hi, I’m totally new to Ruby and programming. I have a code that I wrote.
It’s not correct, but basically I want it to read from CSV file and
write that data into another file. I wrote it, and it looks correct to
me. However, I am not sure why it is not working. Can someone please
help?

require ‘CSV’
filename = ‘Payroll_Data.csv’
require ‘./GP_Macro_Template.rb’
outfile = ‘./GP_Macro_Complete.mac’
output_mac = File.open(outfile,“w+”)
line = 1
write_to_line = 11

CSV.foreach(filename, :headers => true ) do |column|

employee_id = column[0]
upr_code = column[1]
payroll_amount = column[2]

unless (line > 1)
output_mac.puts “Hello this is Line #1
output_mac.puts “Hello this is line #2
line = line + 1
end

output_mac.puts " + employee_id + "
output_mac.puts " + upr_code + "
output_mac.puts " + payroll_amount + "
output_mac.puts " + write_to_line + "

end

What exactly does “it is not working” mean?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs