Need to separate Codes

Input = “97010”,“97012”,“97014”,“97018”,“97022”

I have a input like this …
so i have to match master excelfile which i attached brlow …
so , if these number are matched to master file … then only i have to write in output or else i dont need to get that number in output …

please make one workflow please
CPT Codes Master.xlsx (8.7 KB)

Hi @Nikhil_Katta

Can you try the below

(From row In DT.AsEnumerable()
                         Let cptCode = row.Field(Of Object)("CPTCODES")
                         Where Input.Contains(cptCode.ToString())
                         Select row).CopyToDataTable()

Main.xaml (11.2 KB)

CPT Codes Master.xlsx (9.1 KB)

Cheers!!

2 Likes

thank you this is ok

and also one more condition … sometimes im getting duplicates also in my input…
so i dont need duplicates
and also … i want output as a string not in a datatable

can u please makes these changes also

Hi @Nikhil_Katta

→ Use the assign activity and create a Array of String datatype variable called Arr_Input to store the input numbers in a variable.

- Assign -> Arr_Input = {"97010","97012","97014","97018","97022"}

→ Use the Read range workbook activity to read the excel and store in a datatable called dt.
→ Use the Assign activity to write the linQ Expression to check the condition and to take the matched input.

- Assign -> dt = dt.AsEnumerable.Where(Function(X) Arr_Input.Contains(X("CPTCODES").ToString)).CopyToDataTable

→ Use write range workbook activity to write the datatable variable dt to the excel.

Check the below workflow for better understanding,

Output -
image

Hope it helps!!

Thank you this is ok

and also one more condition … sometimes im getting duplicates also in my input…
so i dont need duplicates
and also … i want output as a string not in a datatable

can u please makes these changes also

Okay @Nikhil_Katta

Then you want the output in String right, check the below,
→ Use the assign activity and create a Array of String datatype variable called Arr_Input to store the input numbers in a variable.

- Assign -> Arr_Input = {"97010","97012","97014","97018","97022"}

→ Use the Read range workbook activity to read the excel and store in a datatable called dt.
→ Use the Assign activity to write the linQ Expression to check the condition and to take the matched input and create a String datatype variable called Output to store the output.

- Assign -> Output = String.Join(", ", dt.AsEnumerable().Select(Function(row) row("CPTCODES").ToString()).Where(Function(code) Arr_Input.Contains(code)) .Distinct().ToArray())

Check the below output for better understanding,

Hope it helps!!

Hey @Nikhil_Katta
please try this solution:
BlankProcess107.zip (9.3 KB)

I used vb.net code:

Dim resultDt As DataTable = masterDt.Clone()

For Each code As String In inputCodesArray
    Dim trimmedCode As String = code.Trim()
    
    If masterDt.AsEnumerable().Any(Function(row) row("CPTCODES").ToString().Trim().Equals(trimmedCode)) Then
        resultDt.Rows.Add(trimmedCode)
    End If
Next

result = resultDt