LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search a 1D array in a 2D array

Hi would like to search all rows in a 2D array to find whether the particular row I'm searching for is in the 2-D array and return the row index of the 1-D array. How do I do it?

 

For example from a CSV file consisting of Name and contact of several people, I want to search if the name and contact keyed in by me is there in the list. 

 

Thanks

0 Kudos
Message 1 of 4
(4,297 Views)

Hi shreya,

 

autoindexing FOR loop might be a great help here: index your rows of the 2D array to compare them with your "keyed in" data…

 

Beware of typos and other problems when comparing strings!

 

Other solution:

Convert your data into an 1D array of (typedef) cluster! Now you could use Search1DArray again…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(4,291 Views)

The algorithm I have in mind is similar to searching a single element in a 1D array. So, after you wire the 2D array to the for-loop and splitt it into 1D arrays, you can compare two 1D arrays (all elements at once).

 

Cheers,

0 Kudos
Message 3 of 4
(4,290 Views)

Autoindexing FOR loop is definately the easiest way to go here.  Be sure to have the Conditional Terminal visible so that you can stop your loop once you have a match.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(4,246 Views)