Therefore, I need to write a set of 4 integers, the values of which differ for every second part of the day. i.e:.
Now it’s obvious that a two-dimensional array (gah of its python, LIST), whose first length is 86400, is quite impractical. Instead, I want to create a text file with 86400 lines formatted as such:
numSec data0 data1 data2 data3 0 .25 .25 .25 .25 1 .25 .25 .25 .25 2 .25 .25 .25 .25 ...
And since the samples are taken, I want to be able to edit this file, no, I want to be able to edit the line of the file, numSec = the second sample was taken. For example, a sample taken in numSec = 2 (2 seconds after midnight) will force my program to edit the file so that:
0 .25 .25 .25 .25 1 .25 .25 .25 .25 2 .70 .10 .10 .10 ...
It seems simple enough, I even read a bunch of posts that demonstrated how to rewrite a single in a text file. The problem is that they all require you to read the entire file. I do not want my program to read 86,400 lines every second.
Thus, we come to my question: can I read one line in a text file, edit it and write to a file without reading the entire file every time I need to make changes?
PS I should note that I am running Ubuntu 12.04 (Precise), and this is for use in the ROS node
PPS This program will work for an arbitrary number of days, so that every "second" information can be read and rewritten many times. Another reason I would like to use the file is that I need to turn off the system, I would like to save the distributions the next time it starts.