LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Want to combine two 2d arrays with different numbers of rows

Solved!
Go to solution

I'm outputting data to a file in 2d arrays, then adding on more and more as it goes, and I'm running into some issues when the size changes.

Download All
0 Kudos
Message 1 of 13
(6,553 Views)

 


@bobholmgren wrote:

I'm outputting data to a file in 2d arrays, then adding on more and more as it goes, and I'm running into some issues when the size changes.


Sorry, something got screwed up there, and it wont' let me edit. 
When the size changes, like the first data is 10 rows, and the second set is 15 rows, the second set is trunkated to 10 rows.
I want to be able to have larger sizes added on later, and the way I'm thinking to do it is to resize the array to add "blank" rows on when needed, so that then it can add. 
Any suggestions?

 

 

0 Kudos
Message 2 of 13
(6,541 Views)

When the size of what changes? You seem to have customized versions of the Read from Spreadsheet File and Write to Spreadsheet File which you did not include. It seems that you were just making string-based versions of the ones that ship with LabVIEW 7.1 (as that is what you appear to be using).

 

To append to an existing file using the Write to Spreadsheet File VI you do not need to read the file into memory and then use Insert Into Array (which is incorrect, as you should use Build Array to append rows). The Write to Spreadsheet File VI already has an "append to file" input. Please review the documentation on the Write to Spreadsheet File VI.

Message 3 of 13
(6,536 Views)

 


@smercurio_fc wrote:

When the size of what changes? You seem to have customized versions of the Read from Spreadsheet File and Write to Spreadsheet File which you did not include. It seems that you were just making string-based versions of the ones that ship with LabVIEW 7.1 (as that is what you appear to be using).

 

To append to an existing file using the Write to Spreadsheet File VI you do not need to read the file into memory and then use Insert Into Array (which is incorrect, as you should use Build Array to append rows). The Write to Spreadsheet File VI already has an "append to file" input. Please review the documentation on the Write to Spreadsheet File VI.


 

Yeah, sorry, I am using modified read and write to use strings. 

 

Write to Spreadsheet file does not allow data to be appended in extra rows, only in the first and second column. 

 

Basically, here's my question:

 

If I have an array that looks like this:

 

X Y

X Y 

 

how can I add on an array that looks like this:

 

Z T

Z T

Z T

 

So that the result looks like : 

 

X Y Z T

X Y Z T

      Z T

 

instead of just truncating to:

 

X Y Z T

X Y Z T

0 Kudos
Message 4 of 13
(6,531 Views)
Solution
Accepted by topic author bobholmgren

2D arrays must be rectangular, so those empty space you have there will be filled in with the default value of whatever datatype you use. See attached for concatenating the arrays:

Message 5 of 13
(6,525 Views)

Awesome, thank you very much. 

 

So because I'm using strings, they'll be strings of null length like "" ? perfect

0 Kudos
Message 6 of 13
(6,517 Views)

I tried that, and got the error in the attachment.

Did I do something wrong?

 

As you said before, I'm in Labview 7.1

0 Kudos
Message 7 of 13
(6,516 Views)

 


@bobholmgren wrote:

I tried that, and got the error in the attachment.

Did I do something wrong?

 

As you said before, I'm in Labview 7.1


 

Ah, I got it, had to concatenate inputs. Thank you so much!

Wish I'd known that before, this is the same problem I ran into when I initially coded it, haha, I tried doing it that way first.

0 Kudos
Message 8 of 13
(6,506 Views)

Oh, and btw, the way I had it, I didn't even need to use the transpose data, haha, just the build array with concatenation enabled.

 

Thanks so much!

0 Kudos
Message 9 of 13
(6,499 Views)

 


@bobholmgren wrote:

Oh, and btw, the way I had it, I didn't even need to use the transpose data, haha, just the build array with concatenation enabled.

 

Thanks so much!


That wouldn't have worked. Try it and you'll see. Smiley Wink

 

0 Kudos
Message 10 of 13
(6,495 Views)