LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write delimited spreadsheet only writes once in one row

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?

0 Kudos
Message 1 of 11
(3,826 Views)

Got it fixed, I'm stupid. Can someone delete this?

Message 2 of 11
(3,811 Views)

Hi Rofid,

 

Can someone delete this?

 No, don't delete this!
Got it fixed
Please post your solution to help other people reading your thread! (That's how a forum works best!)
 
 
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 11
(3,803 Views)

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?

0 Kudos
Message 4 of 11
(3,612 Views)

@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.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 11
(3,603 Views)

The True constant should have been wired to Append terminal instead... 

CY (expired CLAD)
0 Kudos
Message 6 of 11
(3,583 Views)

append.png

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.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 11
(3,571 Views)

@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!

0 Kudos
Message 8 of 11
(3,564 Views)

@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.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 11
(3,557 Views)

You can open it to allow access by other programs.

0 Kudos
Message 10 of 11
(3,553 Views)