To append to a CSV file in Ruby, you can use the CSV library to open the file in "append" mode and then write to it using the <<
operator. Here's an example:
main.rb253 chars12 lines
In this example, we're opening the file file.csv
in "append" mode using CSV.open
. Then, we define an array of values to append to the file. Finally, we use the <<
operator to append the values to the file. The CSV.open
block takes care of closing the file for us.
gistlibby LogSnag