LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

select column from table

Hi all,

Now I have a 2D array of table contains all the data from database. And I have another 1D array of number to indicate the column / field that I wanted to view it into another table (let's name it Appended Table). May I know how can I display out the data in Appended Table according to the 1D array of number?

For example,  2D array of table may have column (and its data for each column, of course) from 1-9 and 1D array of number contains 1,3,4,9. How can I select out the data column of 1,3,4,9 from the 2D array of table of 1-9?

Pls advise or give example.. THANKS !!!!

0 Kudos
Message 1 of 8
(4,637 Views)
You should use the "index array" fucntion. If you input a 2D array you'll have to specify the index of the line or column you want to get.
Note that if you link just one index the output will be a 1D array corresponding to the index and Line or column.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 8
(4,632 Views)
I'm also understand that I can use the index array to get the data column out according to the row / column index but the 1D array of number is not fixed. How can I solve this?
0 Kudos
Message 3 of 8
(4,629 Views)
I don't see what you mean...
Do you mean that the column you want to extrat from the 2D array is not always the same and depend on the operator's choice ?
If this is what you want to do, you should use a property node on the table to get the index of the selected row (or column), then link this index to the "index array" function.
You see what I mean ?

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 8
(4,627 Views)
If I understood correctly, you have a basi table with data, an array wich contains column-indexes from the basic table and a built table, that contains just the data of the columns specified in the array.
 
So you just have to use a for loop, to select all specified columns of the basic table using the index array function. If you set the output tunnel of the loop to autoindexing, you get a 2D array, which you have to transpose, so that it is displayed correctly.
 
Just have a look at the picture.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 5 of 8
(4,624 Views)
Pls look at the attached jpg file and let me know why the 2D array became 1D after entering the For Loop.

The 1D array of number is a dynamic array. I need to get the data column out from the 2D array data according to the 1D array of number.

Thanks
0 Kudos
Message 6 of 8
(4,619 Views)
This is normal behaviour. If you wire an array to a for-loop, the input tunnel is "auto-indexed". This means for instance in a 1D array, that the loop iterates automatically over all elements - you do not have to wire the iterationnumber to the N-terminal. You always have to take care that either just one array is autoindexed or that all autoindexed arrays are of the same length.
 
To change this, just right-click the tunnel and uncheck "enable indexing".
 
To learn more about this, I'd suggest you to have a look at the LabVIEW-manual.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 7 of 8
(4,617 Views)
Thanks guys... I've managed to do it again.. Smiley Tongue
0 Kudos
Message 8 of 8
(4,613 Views)