1

I was using

CSV.open(filename, "w") do |csv|

to create and write to a file in one ruby.rb file and now I need to open it and edit it in a second .rb file. I need the new file to start writing new rows where the first edit ended.

Any good way to do this? Calling

CSV.open(filename, "w") do |csv|

again overwrites the line that were already written.

1 Answers1

2

The second argument of the open method is the write mode. See here: https://stackoverflow.com/a/17866433/9595653

And also refer to the documentation for CSV here: https://ruby-doc.org/stdlib-2.6.1/libdoc/csv/rdoc/CSV.html

You will want to change the option to "a"

Clara
  • 2,677
  • 4
  • 16
  • 31