LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write column headers in LVM file?

Hello everyone,

I'd like to write column headers in an LVM file. Some signals come from the "Statistics Express VI" and column headers are therefore written already. Others go right into the "Write LVM File Express VI" and have blank column headers. Then I calculate the %CV (not in "Statistics", can't do that) and it gives me "StDev" as column header. So I have the correct headers for the "Statistics" values, the wrong header for %CV and no header for the value that is not processed. I already converted the "Write LVM File Express VI" into a standard subVI to change the reports header. But I don't know how to change column headers.

Any help is appreciated.
Bernd

Attached please find the Report Generation part of
my application.
0 Kudos
Message 1 of 12
(3,843 Views)
Hi Bernd,

The Write LVM File Express VI is a quick and easy-to-use VI that writes a tab-delimited text file that you can open with a spreadsheet application or a text-editing application. However, for better customization of the file generated, you might want to consider using some of the File I/O VIs such as Open/Create/Replace File, Write Characters to File, Write to Spreadsheet File.

I've attached an example program here that demonstrates how to write out to a spreadsheet file with column headers. Also, if you are planning on using Excel to read in your data, you can also consider using ActiveX to communicate to an Excel worksheet. I've included the shipping example that comes with LabVIEW below to this email as well.

Good luck!


Kileen C.
Applications Engineer
National Instruments
Download All
0 Kudos
Message 2 of 12
(3,843 Views)
Hi Kileen,
Thank you for your answer.
I use your first example and I configured the headers to my needs. What I don't know is how to continuously write data to one file. Data can be appended to an existing file, that's good after a restart of the application. But as long as the application runs I'd like to write data on the same file without the headers appearing on every single data point. In the example this is possible for any number of data points. But in my application it just appends data with a new header, maybe because the application is externaly triggered by a photoelectric sensor. How do I write data to one file with only one header per file as long as the application is running?
I've attached part of the application to make myself more
clear.

Thank you very much
Bernd
0 Kudos
Message 3 of 12
(3,844 Views)
Hi Bernd,

I would suggest that you pull out the column header writing portion and place that before you write any signals to the file -- sort of like a file initialization procedure. Therefore, all the string inputs into the Concatenate Strings.vi can be pulled out and placed as a information to write when the file is opened/created. Then, everytime a signal needs to be written out, just feed the output of the Array to Spreadsheet String.vi directly into the Write Characters to File.vi and keep the Append to File boolean set to true like it is currently.

Good luck!

Kileen C.
0 Kudos
Message 4 of 12
(3,844 Views)
Hi Kileen,

I'm new to LabVIEW and I'm afraid I can't follow your instructions. Where do I wire the header information in order to write this information when the file is opened/created? Do I still use the Concatenate Strings.vi? I tried one Characters to File.vi for the header and one for the Array to Spreadsheet String.vi output. That didn't change anything.

Thank you for your patience
Bernd
0 Kudos
Message 5 of 12
(3,844 Views)
Hi Bernd,

Not to worry, that's what we're here for! I've attached a modified version of your LabVIEW program that demonstrates what I was explaining in my previous post. One thing to note, is that the Write Characters to File.vi will continually open and close the file everytime it writes data to that file. If you are performing this operation many times in your program, opening and closing will begin to slow down the operation of your program. You might want to consider taking a look at the Write to File.vi example program that ships with LabVIEW too to see how to use some of our other file I/O VIs.

Thanks again!
Kileen C.
0 Kudos
Message 6 of 12
(3,844 Views)
Thanks for all your help Kileen. I guess you're right, I'll also look into the Write to File.vi since I have thousands of data points accumulating.

Unfortunaltely I'm not able to open the vi that you sent, because it's LabVIEW 7.1 and I have LabVIEW 7. I get "LabVIEW load error code 9:VI version (7.1)is newer than LabVIEW version (7.0)."

Thank you
Bernd
0 Kudos
Message 7 of 12
(3,844 Views)
Hi Bernd,

Sorry about the version types! I've attached a LV 7.0 version to this post.

Thanks again and have a great day! 🙂

Kileen C.
0 Kudos
Message 8 of 12
(3,844 Views)
Hi Kileen, I hope you had a good 4. of July.

I tried your modifications before. But it gives me one header with every single data point. I'd like to have only one header per file. Maybe it's because I have this function in a case structure inside of a while loop.

Thank you Kileen
Bernd
0 Kudos
Message 9 of 12
(3,844 Views)
Hi Bernd,

The header information should be placed outside of the while loop. Because I only have a portion of your code, I am not able to see how this code is incorporated into the big picture. But essentially, the column headers should be written to the file only once and therefore placed outside of the while loop just before you begin to add the data to the file.

Hope this makes sense and good luck!

Kileen C.
Applications Engineer
National Instruments
0 Kudos
Message 10 of 12
(3,844 Views)