From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing header info to continuously updated csv file once

Solved!
Go to solution

Hello,

 

I am attempting to add header information once to a .csv file that is continuously updated. Following an online example, I am able to add the header information, but I only get one row of data, which I suspect is due to the first "write to file" command not having a true append status. Adding that true append status then adds the header to every line of data. Currently I have added a case statement that I was hoping would check if a timer had reached a certain limit and append the header data if the timer value was below a certain threshold, or skip the header if the timer was exceeded. Despite changing the value of the timer condition, the results in the file indicate that the case statement always evaluates as false. I initially has the timer threshold value as 2 ms, but even with a value of 10 seconds the results are unchanged. I would be very appreciative of any help to solve this issue.

true image.JPG

false image.JPG

 

What I have:

wih image.JPG\

What I would like:

wiw image.JPG

 

Because the file is added to constantly, I would like to avoid a solution that involves reading the file constantly and checking if there is data contained within. 

 

Thank you very much for your time.

0 Kudos
Message 1 of 3
(2,527 Views)
Solution
Accepted by topic author CBlevins

I can't open you code because I only have LV2016 here but...

 

In general you do this:

  1. Open a file
  2. Write the headers to your file 
  3. Enter a loop
  4. Write rows of data to the file
  5. Exit the loop
  6. Close the file
========================
=== Engineer Ambiguously ===
========================
Message 2 of 3
(2,519 Views)

Hello RTSLVU,

 

Thank you very much! I'm dissapointed I didn't try that earlier. I pulled the header writing portion out of the external case statement, but not outside of the overriding while loop. Based on your suggestion, I pulled  the header portion all the way out and it worked. 

Message 3 of 3
(2,513 Views)