Flowchart with a word count check and decision making

Hello Uipath Community.

I have built a Flowchart, which selects multiple PDF Files inside a folder and it checks if it fulfills the condition or not.

Therefore, I have taken the word “Machine A” and “Machine B”, these will be counted and saved inside the variables (“Machine A” = wordCountA ; “Machine B” = wordCountB)

Now I want to fulfill the condition that the word count of Machine A is equal or greater than
Machine B, and if the condition succeeds, the result will be listed on an Excel File.

Therefore I would like to add an if activity or Flow decision with the condition:
"wordCountA >= wordCountB ".

Below a screenshot from the flowchart:

If the file fulfilled the condition, the result will be saved in an Excel List with the text “this document full files the condition”.

My Question is how I need to have the correct setup for the If condition to be working, because right now i get an error.

My guess is that I need to convert the wordcountA and wordCountB variable from IEnumerable to Int32, and after the IF condition back to IEnumerable .

How would be the best way to involve the convergation or do you maybe have another solution?

Thanks in advance

Hi @Okan !
What is the variable that you put as an output for matches activities ?
Would you mind sharing with us the workflow without the pdf files ?

Hi @Hiba_B

below I have put a Screenshot from the first matches activity:

The second matches have the same Input.
The pattern would be “Machine B” and the
Output “wordCountB

This Flowchart is a part of a bigger process. But I can cut It out and share it here if its necessary.

Thanks in advance

Ok now I get it better.
So the right condition for you in the if statement is the following:
wordCountA.Count >= wordCountB.Count
No conversion needed here :wink:

Because matches return an IEnumerable as you have seen, you can’t apply an operation on IEnumerable (being it + or - or / or x or > or < etc). But what you want to compare is the number of occurences, and the number of occurences = number of elements returned by matches = number of elements stocked in your IEnumerable variables.
And to have access to the number of elements stocked in your IEnumerable, you just need to add .Count and voilà :smile:

Let us know if it works !


Hi @Hiba_B

thank you very much for the detailed explanation, the error is gone and it worked :smiley:.

I just finished the project and came to another error, maybe you can help me with that too.

While I have a For Each Loop, which checks throw multiple pdf files in a folder (like described above) I get a For Each: Could not find a part of the path error.

I have searched throw the forum but could not find any solution.

thanks in advance

Great that the solution fits you !
For your error, there are many sources of errors. To understand better, would you mind running in debug mode your code ? Then copy/paste your whole UiPath Studio screen once the error happens. What we need to see is the variable panel :wink:
Then we need to see that panel, that’s what you need to screenshot us + the remote exception that it throws

Hello @Hiba_B
thank you for your reply.

Below I send you two screenshots when the automation stops during the debug mode.

and the second break:

also a copy of the error during the debug mode copy/paste and as screenshot:


Source: For Each

Message: Could not find a part of the path ‘C:\Users\okan9\Dokumente\UiPath\BA_2\List’.

Exception Type: System.IO.DirectoryNotFoundException

RemoteException wrapping System.IO.DirectoryNotFoundException: Could not find a part of the path ‘C:\Users\okan9\Dokumente\UiPath\BA_2\List’.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator1.CommonInit() at System.IO.FileSystemEnumerableIterator1…ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler1 resultHandler, Boolean checkHost) at System.IO.Directory.GetFiles(String path) at lambda_method(Closure , ActivityContext ) at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context) at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity)
at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor) at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath) at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Alright, thank you.
When you open any windows explorer and copy paste the following path then hit enter, does Windows return an error ? Or does Windows redirect you to the directory level ?

Also please create an array of string

and drag & drop assign to have my_arr = Directory.GetFiles(PfadPDF)
Then in your foreach, instead of putting Directory.GetFiles(PfadPDF) replace it by my_arr.
Then debug your code and screenshot us again the result: we would like to see what are the elements returned by the robot as a local variable for my_arr :wink:

I checked the path on windows Explorer, and it showed me the folder, so no error there.

I added the my_arr variable and still get the same error, as seen on the screenshot.

@Okan it’s normal that my_arr has the error, but what we would like to see is what is fetched inside my_arr variable (the local panel on the top left) with a screenshot.
Also, would you mind sending us a screenshot of what you see on windows explorer when you write the path C:\Users\okan9\Dokumente\UiPath\BA_2\List and hit enter in windows explorer ? You can make the files blurry but we need at least to see the A.pdf inside

Hello @Hiba_B

Below I send you the two screenshots from the currently debug error, with the variable panel.

Also a screenshot from the file path.

This folder has around 100 pdf files in it. The PDF File A is more of a test.
I also tried this with having only one file in the folder, still the same error.

Hi @Okan
If I look at your path up, it’s not okan9 but Okan somethinghidden: you need to take this whole path and put it in the variable PfadPDF :wink:

1 Like

Hi @Hiba_B

yep it worked. I just had to use my correct profile on the PC instad of user.

Thank you very much for all the help!! :clap: :smiley:

1 Like

You’re welcome :grin:
Happy automation !

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