LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparison Of 1D array of Strings to a string with multiple lines

Is there a way that I can compare each line of a string to each line of a array? I have the following info:

1D Array:

100+ rows of the following: Serial  Model  Station  Operator  Date/Time

 

and

 

String:

50+ rows of the following: Serial

 

I am needing to compare the string "Serials" to ALL of the Array "Serials", and if the 2 serials match, I need a count of how many match along with "Operator"

 

 

Basically I am comparing completed products to the tests status across the floor. If the product fails, I need to be able to show the operator how many fails that they have.

 

Thanks in advance.

0 Kudos
Message 1 of 4
(3,876 Views)

Yes, you can do this. Can you upload a VI with sample data, so we can see exactly how it's formatted?

 

I can think of a couple of possible approaches, depending on the data. One is using Spreadsheet String to Array in a loop to convert each line of the 1D array into its own 1D array, then combining all those into a 2D array. Then you can extract the column of serials, and from there it's easy to count how many matches there are. You also want the index of each of those matches, so that you can pull out the operator from the 2D array.

 

Another option would be checking if the beginning of each string in the 1D array matches the serial, and if so, then convert that array element into an array so you can easily extract the operator.

 

Again, if you provide sample data along with whatever code you've already tried, we can help get it working.

0 Kudos
Message 2 of 4
(3,865 Views)

The simplest way is to use a For loop.  Run your array into the For loop.  You should get an "indexing terminal" on the left-hand edge (it looks like a box-within-a-box).  Inside the loop, you have an element of the array, namely a single string.  You should not wire anything into the "N" terminal of the For loop -- with this construction, it will loop once for every element of your String array.

 

Now, inside the loop, compare the (single) Array element with your test string.  You can use the loop index to tell you which element you are activating.  Do you know about creating a conditional Output Indexing tunnel?  That's a method that would let you output an array of the indices that match, or the indices that don't match (or whatever else you wanted).

 

Bob Schor

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

I figured it out. Thanks

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