LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Parsing

Solved!
Go to solution

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

0 Kudos
Message 1 of 11
(3,111 Views)

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.)

0 Kudos
Message 2 of 11
(3,105 Views)

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

 

 

Download All
0 Kudos
Message 3 of 11
(3,083 Views)

@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.

0 Kudos
Message 4 of 11
(3,075 Views)

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

0 Kudos
Message 5 of 11
(3,055 Views)

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.

 

altenbach_0-1591554344127.png

 

 

0 Kudos
Message 6 of 11
(3,049 Views)

@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:

 

altenbach_0-1591554171084.png

 

 

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.

0 Kudos
Message 7 of 11
(3,045 Views)
Solution
Accepted by topic author Scot07

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)

 

altenbach_0-1591555238155.png

 

Message 8 of 11
(3,033 Views)

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

0 Kudos
Message 9 of 11
(3,024 Views)

@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)

 

altenbach_0-1591555238155.png

 


Not sure why I didn’t previously realize you could nest maps within maps. Nice 👍.

 

mcduff

0 Kudos
Message 10 of 11
(3,015 Views)