LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding Write-to-Text file to fix data appendix issue

Hello,

 

I'm trying to fix an issue with a labview program provided to my company from a 3rd party, specifically with regards to writing data to a .csv file.

To summarize, this program reads a variety of data from a Power-Supply system thru a single USB-6001 DAQ, and exports said data to a .csv file on command.  Everything about the program seems to work fine, EXCEPT for the fact that the first line of data accidentally gets added to the text header row.  So instead of having a clean row of headers that looks like: 

 

|| Date || Time|| kv Setpoint || .... || Filament Current || Filament Under Current Status || Fault ||

 

my top row actually looks like:

 

|| Date || Time|| kv Setpoint || .... || Filament Current || Filament Under Current Status || Fault5/22/2026 || 57:15.0 || 0 || ...  || -0.109 || 0 || 1 ||

 

Unfortunately, I can't attach the full source code, due to proprietary issues.  But if anyone knows a good resource that covers how to Write to a Text file WITHOUT ExpressVIs (as for some reason that's the only thing that pops up when I try searching for the issue) please let me know

0 Kudos
Message 1 of 4
(146 Views)

Hi nim,

 


@nim87 wrote:

Everything about the program seems to work fine, EXCEPT for the fact that the first line of data accidentally gets added to the text header row.  So instead of having a clean row of headers that looks like: 

 

|| Date || Time|| kv Setpoint || .... || Filament Current || Filament Under Current Status || Fault ||

 

my top row actually looks like:

 

|| Date || Time|| kv Setpoint || .... || Filament Current || Filament Under Current Status || Fault5/22/2026 || 57:15.0 || 0 || ...  || -0.109 || 0 || 1 ||


In CSV files you typically use a linefeed/LF (and/or carriage return/CR) char to end a "row": did you forget to add that LF char to your header line before writing the next line/row?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(100 Views)

Simple solution. It's better to open the file ref and use the reference, but this should work for you.

Yamaeda_0-1780584879404.png

 

Resulting .csv

Date Time Setpoint Filament
0.581 0.663 0.515 0.058
0.218 0.862 0.360 0.682
0.220 0.707 0.804 0.516
0.223 0.979 0.853 0.278
0.661 0.040 0.937 0.259
0.219 0.513 0.043 0.259
0.758 0.744 0.213 0.555
0.865 0.510 0.721 0.836
0.318 0.098 0.203 0.758
0.300 0.782 0.488 0.610

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 4
(64 Views)

I use the file primitives these days because this method has a couple advantages.

 

  1. It opens the file once and closes the file once
    1. This has a performance advantage over the Express VI and Write to Delimited Spreadsheet because those VIs opens and closes the file on every write
  2. Having the file open prevents users or other program from opening the file while the LabVIEW program is running.
    1. Windows will Lock the file access preventing a Sharing Violation that will crash your LabVIEW if someone open the file between writes while using the Express VI or Write to Delimited Spreadsheet

wtfCapture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 4
(30 Views)