LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Headers with Data Underneath

Hello all, I am pretty new to labview, and I've seen variations of this question asked, but none have really quite answered it the way I need it to. So my question is this: I want to put data underneath column headers, then append only the data. Right now I have it set up so it appends both the header and the data every run. I will attach the code I am using, the output file that my code produces, and the sample file which is what I would like my output file to look like. The files attached are .xls but I will be using .csv. (Attachment issue) Thanks in advance.

Download All
0 Kudos
Message 1 of 22
(3,077 Views)

Hi Szklanam,

 

as surely was written in older threads: you have to create the header once when creating the file. Afterwards you only append the measurement data...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 22
(3,068 Views)

Thank you, now how would you go about doing this on a "Write to Text File" block?

0 Kudos
Message 3 of 22
(3,059 Views)

Hi Szklanam,

 

I'd consider doing this using the 'Write to Spreadsheet' VIs. This link shows how you can add a header to the spreadsheet file.

 

Hope it helps,

 

-CC 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 4 of 22
(3,053 Views)

And additionally the context help for that function explains how to append new data to a file using that function...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 22
(3,051 Views)

Good advice Gerd. The context is always your friend when using new functions. You can also click on the 'detailed help' text to get a much more detailed breakdown of the VI.

 

-CC 

 

 

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


0 Kudos
Message 6 of 22
(3,049 Views)

Which context help? The "Write to Spreadsheet" or "Write to Text File"? They both sort of lack description when it comes to appending new data. The append section of the "Write to Text File" help is awful. It mentions something about the EOL but doesn't really describe how to append data. And for the link, that way is not working. I assumed that on the first "Write to Spreadsheet" block I would be attaching the header, and then set the append to file terminal to false or leave it blank. Then the second "Write to Spreadsheet" block would be my data and then that would have the append to file terminal set to true. That setting will not let me run it through a loop. I get the last data value with no headers. Or if I switch up the settings I just get what I've been getting

0 Kudos
Message 7 of 22
(3,036 Views)

Hi Szklanam,

 

the context help for "Write to Text file" says "If you wire a file refnum to the file input, writing begins at the current file position. To append to an existing file, set the file position to the end of the file by using the Set File Position function." as can be read here...

 

You wrote:

"Then the second "Write to Spreadsheet" block would be my data and then that would have the append to file terminal set to true. That setting will not let me run it through a loop."

Why can't you use a loop here? Which "setting" are you talking about?

 

"I get the last data value with no headers."

Isn't that what you want? To write the latest data values without a header?

 

Why don't you attach a VI to show what you have programmed so far?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 22
(3,033 Views)

I would write the headers as part of my create file routine.  Then you just add the data to your file until you are done and close it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 22
(3,022 Views)

I can only attach snippets due to company policy. I have an array constant of string type with my headers, and an array of string type which includes my data. My header constant is going into the first "Write to Spreadsheet" 2D array terminal, the delimiter is a comma, append to file is false, and there is a file path going into the file input terminal. The file out is going to the file in of the second "Write to Spreadsheet". My data string is converted to a numeric array with "Format Value" block with the format of %0.6f and the delimiter is a comma. This goes to a for loop with auto indexing, and then from there goes to the 1D array input of the second "Write to Spreadsheet" block. The delimiter for this "Write to Spreadsheet" block is also a comma, and the append to file for the second "Write to Spreadsheet" block with the data coming into it is set to true. So my thinking about this is that the first "Write to Spreadsheet" block reads in the headers, the append is false so it will not append anything else, and the second "Write to Spreadsheet  is in a loop that knows when the array is done, and that is appending so each new value would append depending on the number of tests I do. But what happens is I either get no headers and one set of numbers (The last run to be completed), headers and data (only the last run to be completed) or headers and data for each run instead of just getting one set of headers then data for the rest of the runs.

0 Kudos
Message 10 of 22
(3,020 Views)