Thursday, 22 August 2013

Write value to CSV Column with RUBY

Write value to CSV Column with RUBY

I have a column with headers as such:
First,Last,ID,Type
The first row of data looks like this:
Jon,Smith,123,,
As you can see, there is no value in the 4th column Type
I have a ruby script that essentially parses each column into an array and
does different actions based on the first three criteria, First,Last,ID.
What I need is to write within my Ruby script something to write to the
CSV file. So the logic would look like this:
If First == Jon, Last == Smith, and ID == 123, write "Success" to Type
I have the following ruby script:
CSV.open("Content_File.csv", "wb") do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
But all it does is write content to a CSV file row by row. I need to write
to a specific row and a specific column.
Any thoughts?

No comments:

Post a Comment