LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to "query" a 2D array with pseudo-SQL code?

Hi all,

 

I'm using LabVIEW 2016. I have a TDMS file to which I'm recording data almost in a database-table style, in the sense that I have an index column that I want to use to pull out rows that have a matching value of the index column. 

 

Now I can get the 2D array using TDMS Read. But then to pull out the rows that have a requested index column value, I have to go through multiple hoops of getting the value, then looping through each row and collecting the rows with matching index column values. 

 

With SQL, I can accomplish this with a very simple query:

select * from [2D array] 

where [Index Column]=1

 

Except, instead of a formal database table, I have a 2D array (essentially a table). 

 

Is there such a "pseudo SQL" way to do this in LabVIEW?

 

Thanks!

0 Kudos
Message 1 of 6
(3,794 Views)

Multiple hoops?  Is there something wrong with doing it like this?

Array Index Search.PNG

0 Kudos
Message 2 of 6
(3,774 Views)

I did that exact for loop first. But it's not very convenient or scalable. If I want to do a more complex data extract, I'd have to do more of these clumsy operations. At least if there was a "Search 1D Array" that would find all instances of a value, it would make the code a bit more compact. 

0 Kudos
Message 3 of 6
(3,755 Views)

OpenG toolkit has one such function that returns the indices of the array that match your value.  You can install it from VIPM. 

aputman
0 Kudos
Message 4 of 6
(3,747 Views)

@abvenk wrote:

... I'd have to do more of these clumsy operations. At least if there was a "Search 1D Array" that would find all instances of a value, it would make the code a bit more compact. 


There is nothing clumsy about this code, it is quite elegant. To make the code more compact, turn it into a subVI. 🙂

 

What "more complex" searches do you need to do?

0 Kudos
Message 5 of 6
(3,727 Views)

In case the OP was unaware, one can use SQLite (full SQL database-in-a-file) in LabVIEW.  

0 Kudos
Message 6 of 6
(3,714 Views)