LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing first line in text file... Memory and HD concern

Hello all,

I want to remove the first line of a text file. This is easy... One way to do it, is to find the first "end of line" caracter, strip the string and re-write the sting in file with the "strip to sreadsheet" VI.

Since the file can be quite large (about 120000 lines), is this a good way to do it. Will it re-write all the line or just moving the "begin of file" pointer to the second line? If it re-write the whole file, this option is not very good since I could have to do this operation quite often. (I want the file to be a kind of circular buffer / backup).

What do you think is the best way to do this?

Thanks!

Vincent
Message 1 of 2
(2,799 Views)
I think you would have to read in all the data and write it to a new file, you could either keep the data in RAM or simply write to another file then delete the original, and then rename the temp one.  So obviously that is a lot of data and memory.
 
My main question is are you trying to use a text file as a circular buffer?  If so can you tell us more about the data, ie is it strings of a constant length?  Does a user ever need to read the file or could we head binary?
 
A solution would be to truly make the file a binary file, so you could actually seek through the file easier, and maybe make the first data chunk the location of the most recent write.  The obvious danger is then writing over existing data.  This solution is still risky because of the data writes.
 
You may want to look at some of the other file formats like HWS which maintains a hierarchy of data for you so you can simply add and remove data from it.  However, a user will not be able to easily read it.
 
 
 
0 Kudos
Message 2 of 2
(2,791 Views)