I have some doubt in the data table.
Requirement:
I need to filter the data table which contain 7 column and in that we need to check the unique and keep one in the unique.
Case with same “Account id” or “Division” or “Customer name” value column of the SQL application has been already processed on the same received date
example data table.
Name
Account ID
Division
Date recived
A
123
AA
01-12-2024
B
234
AA
01-12-2024
B
123
AA
01-14-2024
D
123
BH
01-12-2024
D
123
BG
01-12-2024
Also I need duplicates also because i need to update those value in another excel
→ Take Excel Process scope activity and insert the Use excel file activity inside of it.
→ Give the path of the excel file in Use excel file activity.
→ Inside Use excel file activity, use remove duplicates activity.
→ In Remove duplicates activity, Select compare individual columns option and give the columns where you want to remove duplicates.
Check the below workflow for better understanding,
Update the case as business exception as “Duplicate account found” if the case with same “Account id”, “Division” and “Customer name” column of the docuware application has been already processed on the same received date.
Hear Receive date ween Need to check example I gave below.
We have Account id”, “Division” and “Customer name” and “Date received”
Received date column is we need to check once we check other 3 column Account id”, “Division” and “Customer name” in this any one once is matched then that will consider as duplicate.
If you find the solution for your query please mark my post as solution to close the loop orelse if you have any questions, let me know. I’m happy to help.
// Read the CSV file into a DataTable
string filePath = "C:\\path\\to\\input.csv";
DataTable dataTable = new DataTable();
using (var reader = new StreamReader(filePath))
{
string[] headers = reader.ReadLine().Split(',');
foreach (string header in headers)
{
dataTable.Columns.Add(header);
}
while (!reader.EndOfStream)
{
string[] rows = reader.ReadLine().Split(',');
DataRow dataRow = dataTable.NewRow();
for (int i = 0; i < headers.Length; i++)
{
dataRow[i] = rows[i];
}
dataTable.Rows.Add(dataRow);
}
}
// Create two new DataTables for storing non-duplicate and duplicate rows
DataTable nonDuplicateDataTable = dataTable.Clone();
DataTable duplicateDataTable = dataTable.Clone();
// Iterate through each row in the DataTable
DataRow previousRow = null;
foreach (DataRow row in dataTable.Rows)
{
// Check if the current row is a duplicate based on Account Number, Division, and Customer Name
if (previousRow != null &&
(row["Account Number"].ToString() == previousRow["Account Number"].ToString() ||
row["Division"].ToString() == previousRow["Division"].ToString() ||
row["Customer Name"].ToString() == previousRow["Customer Name"].ToString()))
{
// Duplicate found, add to duplicateDataTable
duplicateDataTable.ImportRow(row);
}
else
{
// Non-duplicate, add to nonDuplicateDataTable
nonDuplicateDataTable.ImportRow(row);
}
// Update previousRow for next iteration
previousRow = row;
}
// Output non-duplicate and duplicate DataTables
nonDuplicateDataTable
duplicateDataTable