LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert rows into columns when saving to file

Solved!
Go to solution

Hi everybody,

I have a sort of basic problem. I am saving some calibration data into a file as in this example: https://forums.ni.com/t5/Example-Code/Write-Multiple-Columns-With-Write-to-Spreadsheet-File-VI/ta-p/...

My only problem left is, that it does not save the data in columns but in rows, and nothing seems to change that. Does anybody see the problem in my vi? it is supposed to look like the excel file attached...

I am using LV 2014.

Any help appreciated.

Best,

P

Download All
0 Kudos
Message 1 of 5
(1,858 Views)
Solution
Accepted by topic author Phil7

You have several Array to Spreadsheet strings which put a linefeed at the end of that short section and breaks the chunks up into different rows.

 

Build a single 1-D array of your data.  Then write that to your Write Spreadsheet Array.

The cluster and convert to array serves no purpose.

Neither does the Replace Array Subset.

 

Your header string consists of comma delimited titles.  Your data consists of tab delimited values.

 

0 Kudos
Message 2 of 5
(1,833 Views)

Thanks, seems to be working fine. The cluster is only a replacement for the variable I normally use...

Two more questions:

1. Is it possible to remove the zeros in the file? When I only have one value, the rest of the array is completed with zeros.

2. How can I add a time stamp in a column? Do I have to transfer it into an array as well? I don't seem to find the right conversion.

 

Thank you,

phil

0 Kudos
Message 3 of 5
(1,770 Views)

Hi Phil,

 


@Phil7 wrote:

Two more questions:

1. Is it possible to remove the zeros in the file? When I only have one value, the rest of the array is completed with zeros.


The array contains zeros because this is the default value for numeric datatypes. And because arrays need to be rectangular: all rows/columns will have the same length in a 2D array!

So the simple solution would be to use always 1D array of the same length before creating the 2D array…

 

You can filter the zeros after conversion to strings:

Why do you use BuildCluster at all when you convert to array right next? Use arrays instead…

That "Array" control is left empty in your VI and so results in a row of empty strings in the 2D string array. When you don't want this you need to add one more check to your VI to prevent appending that "Array" at all. (I would also use a better label for this control!)

 


@Phil7 wrote:

2. How can I add a time stamp in a column? Do I have to transfer it into an array as well? I don't seem to find the right conversion.


As you now already work with a string array it becomes very easy to add one more row/column with timestamps formatted as strings…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(1,767 Views)

Cool, works perfect. Thank you.

As mentioned before, the cluster is only as a subsitute for my input of my real vi, I know that it is unnecessary in this case.

Have a nice day,

Phil

0 Kudos
Message 5 of 5
(1,747 Views)