04-16-2015 11:44 AM
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.
04-16-2015 12:08 PM
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.
04-16-2015 12:22 PM
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
04-17-2015 04:55 AM - edited 04-17-2015 05:20 AM
I figured it out. Thanks