How do i filter the Data From datatable using the Extracted String From PDF File

Hello

I want to filter the Data From datatable using the Extracted String From PDF File.

I have One PDF File, From which I need to Extract the Client Name (I have done using the Read PDF Text and String Manipulation)

After Scrapping the client Name i need to check that name in excel and filter the Data using that name (i have done using the Filter Datatable activity)

Attached Document

PDF:-
PDFMailer1121 - Copy.pdf (88.2 KB)

Excel :-

Data.xlsx (9.7 KB)

I want to filter the data, As i have Tried but Data filer is not working properly. as String of client name consiste some issue.

You can try to enhance the filtering by e.g. Trimming / Harmonizations

Assign Activity
dtFiltered =

(From d in dtData.AsEnumerable
Where d("Client Name").toString.Trim.Equals(searchNameVar)
Select r =d).CopyToDataTable

Handling empty filter results we can do:
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

can you tell / show more?

@kishan.savaliya

Read PDF to extract clientName.
Read Excel into originalDataTable.
Use LINQ to filter data into filteredDataTable.

use this linq:

filteredDataTable = originalDataTable.AsEnumerable().Where(Function(row) row.Field(Of String)(“ClientName”) = clientName).CopyToDataTable()

Cheers…!

@ppr

i have tried both Solutions but not achieved output.

PFA Code

Data.xlsx (9.7 KB)
forum.xaml (20.2 KB)
PDFMailer1121 - Copy.pdf (88.2 KB)

debug the code and check the Filter datatable and LINQ

@kishan.savaliya

hi i have gone through your code,

the issue is with the value which your are comparing from the excel

you just need to rewrite the values which are there in your excel

in general we can short cut by

When comparing the values
grafik

we can check more in detail

we do see space (32) vs Nonbreaking Space(160)

And can confirm:
grafik

So we can rewrite the LINQ to

(From d in dtData.AsEnumerable
Let cn =d("Client Name").toString.Trim
Where cn.Equals(FinalClientName.Replace(chrW(160),chr(32)))
Select r =d).CopyToDataTable
1 Like

@ppr Oh Great its working fine. Thanks Much… i learnt new things from you

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.