So I’m running a test and it feeds its results out to a html or a xls file. This is great. However, when I go on the file, as expected the test that was run last is at the bottom. I want it at the top so that its easy to get too. is this possible?
I’ve tried using, r, r+, w, w+, a, and a+. They can delete whatever is already there but not write above it.
Is it possible to do something even harder and get it to print my results below a header, and above the previous results? Thanks.
This is not Ruby but OS specific. There is no operation to “write on top” of a file like append for writing stuff to the end.
You have to read in the file, edit the contents and write it back out. You can do this line-based, i.e. reading the first lines, writing them, write your extra content, write back the rest of the lines.