LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving 2D Array and Time into Spreadsheet

I have been working on a code that takes temperature values from a thermocouple data acquisition device. Basically, I had to convert the data (from the waveform) into a decimal string. I did this so I could insert it into an array with time. I was having trouble with this and this is the only way I could get it to work because the time is a string and the data is a double 2D array. However, the data is saved but the Channels and data are all in 1 row rather than being in separate columns. I need help fixing this, in addition taking advice how I can have 1 column just being time. 

This is what it looks like: (the | represents a new column) 

Ignore the NA it because I do not have a temperature sensor connected to that channel.

 

Channel 1, Channel 2, Channel 3, etc., Time |

72, 72, 72, NA, NA, NA, 1:00    | 

72, 72, 72, NA, NA, NA, 1:01    |

 

 

 

I want it to look like:

 

Time  |   Channel 1   |   Channel 2   |   Channel 3  |  etc.

1:00      72.1                72.1              72.1  

1:01       72.2               72.2               72.2

 

Here is my VI and an excel file that saved

Download All
0 Kudos
Message 1 of 4
(2,204 Views)

We don't have your hardware&drivers, so we cannot test your code.

I assume that you get a 1D DBL array with each iteration of the while loop which you want to append to the file as a new row. Who wrote this code? (looks like it was written 25 years ago with all these stacked sequences and sequence locals. Nobody does it anymore like that. 😮

 

Did you know that "index array" is resizeable? No need for 8 instances and no need for dynamic data.

 

personally, I would open the file using lowlevel functions before the loop, write the headers, then append rows in the loop, and close the file once the loop is done.

 

0 Kudos
Message 2 of 4
(2,174 Views)

See if this can give you some ideas...

 

 

0 Kudos
Message 3 of 4
(2,165 Views)

You can also do something like the following to replace your stacked sequence structure:

Example_VI.png

 

Here I take the clusters of "Type" and "Active" via an array (see FP comment) to a For loop and avoid the use of a Case Structure by using the Select node.

In the diagram above, there's nothing hidden - all of the necessary code can be seen at once (and without taking up a lot of space).


GCentral
0 Kudos
Message 4 of 4
(2,150 Views)