03-02-2018 03:19 AM - edited 03-02-2018 03:26 AM
Hi,
I want to write data into an excel sheet, but I'm having a problem: whenever I run the code I do get a file, but it only has one row with some information in it. Whenever I run a sample code I find online everything works fine, but I can't see what I'm doing wrong here!
It seems like the file keeps overwriting itself, because the last value of the controls get saved, but I'm not sure why, could someone help me out?
03-02-2018 03:52 AM
Got it fixed, I'm stupid. Can someone delete this?
03-02-2018 04:06 AM
06-12-2018 02:48 PM
This isn't stupid because I have the same problem and I don't know how to fix it! I'm very new to LabVIEW. Could you please explain what you were doing wrong?
06-12-2018 03:08 PM
@Rofid wrote:
Got it fixed, I'm stupid. Can someone delete this?
I've found that if I post the stupid solution, I don't feel so bad because I will have saved someone else from the same fate. 😉
06-13-2018 02:51 AM
The True constant should have been wired to Append terminal instead...
06-13-2018 09:47 AM - edited 06-13-2018 09:49 AM
Append to new file defaults to "new file" so it makes a new file (overwriting the previous file) every time you use it.
Why?
All I can guess is that NI thinks we would rather place all of our data in a huge array keeping it in RAM and then write it all to a file at once at the end of our programs, instead of writing data to the file one line at a time as it is acquired and processed, so if something happens you will at least have a partial data file.
06-13-2018 09:59 AM
@RTSLVU wrote:
Why?
Because using this function over and over to append is inefficient because it constantly opens and closes the VI. Once you append to a file continuously, you should use lower level function, open the file once before the loop, and close when done. Much less overhead!
06-13-2018 10:20 AM - edited 06-13-2018 10:21 AM
@altenbach wrote:
@RTSLVU wrote:
Why?
Because using this function over and over to append is inefficient because it constantly opens and closes the VI. Once you append to a file continuously, you should use lower level function, open the file once before the loop, and close when done. Much less overhead!
I guess that makes sense, actually I do open a file once with the Open/Create/Replace File primitive and pass the reference, then close it at the end.
But mainly because using this method Windows locks the file as long as LabVIEW has it open, so no other program can access it. If you try to open the data file in say Excel while the program is running Windows will automatically open the file read only or offer to open a copy.
Doing this using the write to delimited spreadsheet.vi, Windows will allow you to open the file just fine but if your LabVIEW program is still running it WILL crash with a file sharing violation when it tries to write to the file.
06-13-2018 10:24 AM
You can open it to allow access by other programs.