The Ruby script i am writing is going to be run every morning and will pull information about backup files and write them to a csv file. This file has column names on the first line.
I have gotten it to work by appending to the end of the file:
open("#{curDir}/Backup_Times.csv", 'a') do |f|
...
end
I would like to see the newest data first without having to sort in Excel.
In Ruby, is there a way to write this data starting at the 2nd line of the file?
You write a new file, applying your change at the desired line, then rename result back to the original file name. The following method will copy the file and yield the output file object to a block at the correct line, so that block can output your new lines.