Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Repeated/Unique Strings/Values 2

Status
Not open for further replies.

jtm2020hyo

Technical User
Dec 30, 2021
24
PE


I have an Variable like this:



ArrSource = A1,B2,C1; A2,B2,C1; A3,B2,C2; A4,B2,C2;A5,B2,C3; A6,B2,C4; A7,B2,C5;

'Note: ArrSource is String



How can I count all "C*" repeated values, I mean something like this:



1) Convert Arr1 to multiple array:



Arr1 = A1,B2,C1

Arr2 = A2,B2,C1

Arr3 = A3,B2,C2

Arr4 = A4,B2,C2

Arr5 = A5,B2,C3

Arr6 = A6,B2,C4

Arr7 = A7,B2,C5;



2) Then count all repeated value in the index 2 (third column) then store it in a variable in index 0 and their unique/repeated value in index 1



Arr_01 = 2,C1

Arr_02 = 2,C2

Arr_03 = 1,C3

Arr_04 = 1,C4

Arr_05 = 1,C5



3) concatenate such value with the Unique Value in a Variable like this:



ArrFinal = 2,C1 ; 2,C2 ; 1,C3 ; 1,C4 ; 1,C5



Is there some help?
Tags (0)
Add tags
Report
2 REPLIES
Sort:
 
Glad you found a solution - but I remain confused. You keep on insisting that you need a bunch of arrays in your solution ("is there any method that uses SPLIT commnad to separate elements per ";" and "," and convert it in multiple arrays or nested arrays?"), but at the same time only want a summary of the unique values in the third ordinal position/column. Which makes it look to me as if you had decided how you thought this need to be solved rather than letting anyone suggest a different, possibly better way of achieving the result you needed

For example, mikrom's dictionary solution (a version of which would probably be my preferred solution), which would have allowed you to see the count of unique values in any of the columns.

So perhaps I am just failing to understand your real requirements

 
Hi strongm,
I also didn't understand why OP wanted to use only 2D-array for this task. Then I thought that he needed the 2D array because he might want to use it for any other tasks that he did not specify here and I helped him to solve it in this way.
But if it was only about this task, 2D-Array is of course not a good choice: well, now if we have 2 separators we make 2D-array, then if we have 3 different separators, we use 3D-Array and if so in the future some other separators will be added, e.g. if we will have 5, then will we use a 5D-array? Such a solution seems a bit cumbersome to me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top