06-07-2020 11:08 AM
Hi all,
I am looking at parsing information from an array and grouping the data. For the data, there are three positions in which items can go to. There are several hundred various items that can be moved to each position.
I have an array similar to that shown in the attached image - with the exception that this may be hundreds of lines long. I am looking to extract how many of item 1 went to position 1,2 or 3, same for item 2 etc. but grouped by position.
I appear to be going round in circles trying to get this to work. Has anybody done something similar to this? What's the best method to extract this data?
Thanks in advance,
Scot07
Solved! Go to Solution.
06-07-2020 11:14 AM
You are not telling us much, such as your LabVIEW version, but if you have a newer version (2019+), a solution based on "maps" would be trivial. What have you tried?
(You get better help if you would attach a sample VI containing some typical input data.)
06-07-2020 11:46 AM
LabVIEW version is 2020.
I have included an example of the VI.
However, this seems like a cumbersome solution as this will need to be done for each position and for every item. I'm sure there will be a simpler way of doing this.
Thanks,
Scot07
06-07-2020 12:04 PM - edited 06-07-2020 12:13 PM
@Scot07 wrote:
However, this seems like a cumbersome solution as this will need to be done for each position and for every item. I'm sure there will be a simpler way of doing this.
What is "this" and why do you judge a solution before even seeing it???
Please fill the array control with typical data, make that data the default, save, then attach it once more. I am not going to manually enter data from an image.
06-07-2020 12:45 PM
The solution in my VI works in finding the total value of Item 1 in Position 1 but there may be many items and positions so repeating this code for each item and position will be cumbersome. I am not judging a solution before seeing it. I am judging my current solution as cumbersome and saying there is likely to be a better and tidier way of doing this.
I apologize for not having the array filled in my example. I have done this now.
Thanks,
Scot07
06-07-2020 12:56 PM - edited 06-07-2020 01:26 PM
Sorry, I did not wait for your VI but made a simplified version, see attached. You should be able to easily adapt it to your data.
Here's what I meant using a map of maps. Formatting the output in any other way would be trivial to implement inside the last loop.
06-07-2020 01:11 PM - edited 06-07-2020 01:23 PM
@altenbach wrote:
Here's what I meant using a map of maps. Formatting the output in any other way would be trivial to implement inside the last loop.
Here's how the last loop stack could look like to format the output as shown:
Note that the code does not need to know the possible items and blindly counts whatever names occur in the various fields, then increment the counts.
06-07-2020 01:43 PM
OK, it took me one minute to plug in your actual data. All that was needed was changing the indices of the relevant columns:
The only difference is that items are sorted alphabetically instead of numerically (e.g. item 12 before item 2), but that would be easy to fix if needed. I assume that you have real item names instead, so this is irrelevant)
06-07-2020 02:06 PM
Thanks! This seems to work. Never saw map of maps before so looks like I'll be spending the rest of the day getting my head around that.
Thanks again.
Scot07
06-07-2020 02:21 PM
@altenbach wrote:
OK, it took me one minute to plug in your actual data. All that was needed was changing the indices of the relevant columns:
The only difference is that items are sorted alphabetically instead of numerically (e.g. item 12 before item 2), but that would be easy to fix if needed. I assume that you have real item names instead, so this is irrelevant)
Not sure why I didn’t previously realize you could nest maps within maps. Nice 👍.
mcduff