Deleting Top Portion of .txt file

Hey All,

I have my PAC set up where I am constantly appending to a .txt file on the microSD card, 8 data points at a time. A separate chart that is running in parallel constantly checks if there is data in there and pulls the first 8 data points and sends it to a database.

Is there any way that I can delete the first 8 data points so that after I send data to the database, it deletes that from the .txt, and then loops back and references point 1-8 (though in reality because of the shift its 9-16). The reason I want to do this is because I don’t want to keep a running count of how far along I am in the text file, and I also don’t want this .txt file to grow too large.

Thanks!

Not really a good way to do that. Perhaps easier to have separate (maybe daily) files? Where each file is the payload of the data into the database, and will get deleted when the data is safely in the DB?

Perhaps you can do it in the db rather than in the text file?

I had to keep a db size in check, so I simply deleted index 1 before I did the insert.
Here is the PHP code I used (but you could do it lots of different ways, its just a SQL statement really).


mysql_query("delete from temperatures where id = 1") or die(mysql_error());
mysql_query("ALTER TABLE temperatures DROP COLUMN id") or die(mysql_error());
mysql_query("ALTER TABLE  `temperatures` ADD  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY") or die(mysql_error());