04-24-2009 05:33 PM
In my DAQ system, columns represent the channels and each row represent the one scan of the data for all channel. it is easy to get file write by append or overwrite to a exist file. But I sometime want just overwrite new data in last row to a exist file. for example: I have DAQ with 10 channels and scan all channel for three times in each run. So my data file will be 10 columns and 3 rows in each run if I set "append" file. next time I want record the data by "overwrite" (so just one row in 3 scans) in the same file but just overwrite in 11th row (so I will keep all the data I previousely got). How can do this?
Solved! Go to Solution.
04-25-2009 12:34 PM
Hello,
i wrote a longer message but my webbrowser crash and i don't want to rewrite all
But tris this vi and tel if this helps
Best regards
Tinnitus
04-27-2009 12:30 PM
04-27-2009 12:35 PM
hello,
@+
Tinnitus
04-27-2009 12:52 PM
Hi Tinnitus,
when I open the download vi, which asked for "write to spreasheet file (DBL).vi", I ignored because I can not find the vi. the vi I download still can run. I think it instead by "write to spreasheet file.vi". The result I got is still overwrite all but not just last row. I don't know if it is caused by the reason that the "...(DBL).vi" I can not find it.
thanks again for the help!
04-27-2009 01:01 PM
sorry
but i have to go ( 20h00 here)
I don't understand completly what is the problem, the file asked is just an file to enter for the example , you can type
what you want try1.txt for example , then data will be stored in first time, and seconf time they will be replaced with new values
in this same file ( sorry for my english , i 'm in a hurry)
Regards
Tinnitus
04-27-2009 02:21 PM
anyway, I have understood your ideal in the vi. But that will take longer time since it need to read the whole file if the file already be very large. I tried the similar way as this, it caused the program slower. I want to know if there is the way can directly overwrite just on the last row in the file (at least not to read the whole existing file, for example just set the file position to last row then overwrite in that row).
This is question I asked when I took LV trainning class from NI. The tutor can not answer the Q in the calss and said he will give me the answer later, but I still didn't get the answer now.
04-27-2009 03:13 PM
Hi GPIB,
1) when your lines in the text file all have the same length you can easiy calculate the file offset for the last line.
2) when you know the max length of a line you may simply load the last 1024 bytes (or any appropriate size) of the file and only search in there for the last line. Then you know the seek position to overwrite just the last line...
3) when the line length can be anything from 1 to filesize you have to search from the beginning...
04-29-2009 11:51 AM
Hi GerdW,
I tried your method, but when I seek the file position I still need read whole old file. I thought LV should had this function for overwrite last row, and want to to know if there is this function in new version such as 8.6. (i am using 8.0)
thanks for the reply!
04-29-2009 03:34 PM
Hi GPIB Analyzer.
why do you need to read the whole file?
You can:
- get the file size with "Get file size" or "file/directory info"
- set the read position with "Set file position"
You should subtract 1024 from file size, set this as file position, read 1024 bytes. Now analyze this 1kb of data, find the last row, set file position again, write to file. No need to read the whole file.
And as noted before:
How should Labview know the last line in the file without searching for it? You can do this search better than a simple brute force attack