LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I replace a single record in a logfile?

I'm developing a program that saves data to a logfile containing clusters. Every record (cluster) contains data from the tested item. The item can be as many as 400+. The file refnum is opened during the whole test. If the test of item 50 (this will be record 49) failed and needs to tested again I want to replace position 49 (counting from zero) with the "correct" test result, but LabVIEW insists and writes them as record 50 and thus item 50 has records as: 49 (failed; want to delete this) and the correct record 50 (this should be record 49 though...). I thought one should connect the "pos offset" at the desired place where the record should be stored in, but one can't connect to that when using datalog file... . I've also
tried to use the "seek"-vi to position the refnum at the desired location but it ignores it... . What shall I do? I have a working "viewer" for my log-files so they aren't corrupted, everything else is OK. Any suggestions?
//Anders Boussard
0 Kudos
Message 1 of 5
(2,958 Views)
A datalog file is a tough file to edit (appending is easy). I spent a couple of hours of looking at the binary of the datalog file. Although I could develop a way to read the data properly, I could not write to it.
For a less programmatic approach, you can do front panel dataloging (see The LabVIEW User Manual chapter 13). The chapter explains how to very easily delete front panel records. This way you can keep track of the bad logs and manually remove them at your convenience.

Jeremy Braden
National Instruments
0 Kudos
Message 2 of 5
(2,958 Views)
My application has to be fast so that solution isn't applicable. Maybe I'll simply write the logs "online" and don't care if there are several logs for one or more items. How about memory then? Do I have to flush? Is it written to hard drive directly? Another "offline" application could then simply remove the previous, older and errorneous item logs and saving the newest. Of course one would like to do this on the fly, but I'm not sure if I catch up before the next item arrives...
0 Kudos
Message 3 of 5
(2,958 Views)
You do not have to use dataloging, you can write the data directly to disk. Writing to a file in binary is much less structured than datalogging but gives the flexibilty of overwriting records. With binary files you can even write several groups of data at a time so the limiting factor tends to be the speed of your harddrive. Consider using the intermediate file write VIs. As an test, I was able to write different clusters of an arrays having different lenghts to a file and read them perfectly. If your data is of uniform structure, you will have no problems doing the same. Look at the read to binary file.vi and write to binary file.vi for example code to get started. You will have to experiment to get the hang of it.
Chapter 13 of th
e LabVIEW User Manual discusses how to do file I/O and you can also find example code and tutorials on our website.

Jeremy Braden
National Instruments
0 Kudos
Message 4 of 5
(2,958 Views)
You do not have to use dataloging, you can write the data directly to disk. Writing to a file in binary is much less structured than datalogging but gives the flexibilty of overwriting records. With binary files you can even write several groups of data at a time so the limiting factor tends to be the speed of your harddrive. Consider using the intermediate file write VIs. As an test, I was able to write different clusters of an arrays having different lenghts to a file and read them perfectly. If your data is of uniform structure, you will have no problems doing the same. Look at the read to binary file.vi and write to binary file.vi for example code to get started. You will have to experiment to get the hang of it.
Chapter 13 of th
e LabVIEW User Manual discusses how to do file I/O and you can also find example code and tutorials on our website.

Jeremy Braden
National Instruments
0 Kudos
Message 5 of 5
(2,958 Views)