Showing results for 
Search instead for 
Did you mean: 

writing header info to continuously updated csv file once

Go to solution



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
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
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
Message 2 of 3



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