1

I have columns with headers as such:

First,Last,ID,Type

The first row of data looks like this:

Jon,Smith,123,,

There is no value under the fourth column Type.

I have a script that parses each column into an array and does different actions based on the first three criteria, First,Last,ID.

I need to write to the CSV file. The logic would look like this:

If First == Jon, Last == Smith, and ID == 123, write "Success" to Type

I have the following 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?

1 Answer 1

1

Short answer is you cannot (that is, you still need to iterate through the whole file and write out another one). For The longer version, please see here.

Sign up to request clarification or add additional context in comments.

1 Comment

Gotcha. I suppose I could pull all the existing CSV values and just overwrite the file, passing in my new value alongside all the old values. I'll probably just write a new CSV file and do a VLOOKUP though. Thanks for the guidance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.