hello Community I want to identify the duplicates and then alert thode no with adding numbers in front of them and incrementing those no. according to duplicate numbers of value
FOR EXample
INPUT:
Output:
-
Read Data:
- Use the “Read Range” activity if your data is in an Excel file, or use “Read Text File” if it’s in a text file.
- Store the data in a variable, let’s call it numbersList.
-
Identify Duplicates:
- Use the following LINQ query to identify duplicate numbers:
numbersList.GroupBy(Function(x) x).Where(Function(g) g.Count() > 1).Select(Function(y) y.Key).ToList() - This will give you a list of duplicate numbers.
- Use the following LINQ query to identify duplicate numbers:
-
Add Numbers in Front:
- Use a For Each activity to iterate through each duplicate number in the list.
- Inside the loop, use a For Each activity again to iterate through each occurrence of the duplicate number in the original list.
- While iterating through each occurrence, add a number in front of it to differentiate it. You can use a counter variable to increment the added number (index+2).
-
Write Back:
- Write the modified list back to your desired destination using the appropriate activity (“Write Range” for Excel, “Write Text File” for text files).
Find below workflow which will help you to get expected output
Simply use below query
Assign: opDt=Inputdt.clone
Assign: opDt=
(From row In Inputdt
Group row By a = row(“Value”).ToString().Trim() Into grp = Group
From g In grp.Select(Function(r, index) New With {r, index})
Select If(grp.Count() = 1,
opDt.Rows.Add(g.r(“Value”).ToString()),
opDt.Rows.Add(g.r(“Value”).ToString() + “_” + (g.index + 1).ToString()))
).CopyToDataTable()
Thanks
Tushar