LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spreadsheet with 3 columns

Solved!
Go to solution

I have a 1D array with 'X' data, and a 2D array with 'Y1' and 'Y2' data, and I want to export these to a spreadsheet, being each axis in one column.

Is the best way to append each array to the spreadhseet, one by one? If it is, how do I do that?

 

It may have already been posted, but I couldn't find anything under this subject, sorry, and thanks.

0 Kudos
Message 1 of 8
(3,003 Views)
Solution
Accepted by topic author carlosbgois

Append your 1D array to the appropriate column of your 2D array using "Insert into Array".  This will give you a 2D array containing all of your data, in columns.

 

Write the resulting 2D array to your spreadsheet in one fell swoop.

Message 2 of 8
(2,991 Views)

@carlosbgois wrote:

I have a 1D array with 'X' data, and a 2D array with 'Y1' and 'Y2' data, and I want to export these to a spreadsheet, being each axis in one column.

Is the best way to append each array to the spreadhseet, one by one? If it is, how do I do that?

 

It may have already been posted, but I couldn't find anything under this subject, sorry, and thanks.



Your question is not sufficient to provide a final solution, because you did not specify if Y1 and Y2 are rows or columns in the 2D array input.

 

In any case, since you want the output to be three columns, there is no way to to append one by one, because column elements are not adjacent, requiring you to rewrite the entire file with each additional column anyway.

 

Here's one possibility, note that "transpose?" is set to true. Modify as needed.

 

 

Message 3 of 8
(2,984 Views)

DianeS Thanks for your help, let me just make sure I understood it: When I append the 1D array to the 2D array, I still get the 2D array, but with data from the first put into some interval I determine in the 'insert into array' function, right?

 

Supposing I have Y1 in the first row, Y2 in the second, and X in a separate 1D array. I can append X either into the first or second rows on the Y1/Y2 array, and then I write the resulting array to my spreadsheet, is that correct?

 

But then, in the file created, wouldn't I get the X and Y1 (supposing I appended to the first row) in the same column, and Y2 in a separated one?

If the answer is yes, how can I make the file with 3 columns, one for each axis (X, Y1, Y2)?

0 Kudos
Message 4 of 8
(2,980 Views)

altenbach, thanks for your help too, but I also didn't get your way quite well. It looks like it's a variation of DianeS method.

 

When you use 'build array' with a 1D and a 2D array as inputs, what do you get as output? I thought it would be a 3D array, but it seems like another 2D array, and where is the X data placed in it? Also, if I get, as output, a 2D array with X, Y1 and Y2 data, how is it possible that in the file it appears as 3 columns?

 

sorry if what I said isn't very clear, hehe

0 Kudos
Message 5 of 8
(2,973 Views)

If your data is in rows, then yes, you can insert your 1D array into the appropriate row of your 2D array, also using "Insert into Array".  Just wire the row instead of the column.  Now you have a 2D array where each row contains one of your axes.

 

Then transpose the resulting 2D array.  Now your data is in columns instead of rows.

 

Altenbach's method of using "Build Array" will also work nicely, if your data is in rows.  Note that he does the transpose with the "Array to Spreadsheet" function instead of doing it as a separate step.  I assumed your 2D data was in columns, since that's what you said you wanted, in which case "Insert into Array" is a better solution, for the reason altenbach mentioned.

 

If your data is in rows, do it altenbach's way.  🙂

Message 6 of 8
(2,965 Views)

@carlosbgois wrote:

altenbach, thanks for your help too, but I also didn't get your way quite well. It looks like it's a variation of DianeS method.

 

When you use 'build array' with a 1D and a 2D array as inputs, what do you get as output? I thought it would be a 3D array, but it seems like another 2D array, and where is the X data placed in it? Also, if I get, as output, a 2D array with X, Y1 and Y2 data, how is it possible that in the file it appears as 3 columns?


Well, the above image is a snippet, so you can place it on your diagram to create a fully working VI, even with default data in the controls.

 

"Build array" is highly polymorphic and adapts to the inputs in reasonable ways. For example if you use build array with a 1D array and a scalar as inputs, you append or prepends the scalar, keeping the array 1D. Similarly, here we have a 1D and a 2D array, creating a 2D array with an aditional row. If both inputs have the same dimension, we can right-click and chose concatenate mode if so desired. The possibilities are nearly infinite. 😄

Message 7 of 8
(2,963 Views)

Clearly, thanks, I wasn't thinking straight, maybe my doubt didn't even make sense hehe, sorry about that.

Thank you two

0 Kudos
Message 8 of 8
(2,956 Views)