Matching user input to name

Hi everyone,

I have an Excel file with 2 columns: names and hobbies. In column ‘‘names’’ there’s different names like ‘‘John’’, ‘‘Peter’’, ‘‘Sarah’’ etc. In hobbies you find hobbies like ‘‘hockey’’, ‘‘fishing’’, ‘‘gaming’’ etc.

My project is supposed to read an email. These emails always have the same format, the only thing that is different are the values after ‘‘hobbies’’.

Here’s my question: how do I make it so that my project makes a match between the names and hobbies? For example, John is assigned to the hobby ‘‘fishing’’ and Carol is assigned to the hobby ‘‘dancing’’. If an email comes in with the subject ‘‘dancing’’, the project needs to show ‘‘Carol’’.

I hope it’s not too confusing, thank you for the help!

Hi @Nomad ,

A format example would help us to provide a much better suggestion.

However, assuming that you are able to extract the value after hobbies.
The Operation should be possible with the help of Look Up Datatable Activity.

You read the Excel sheet as a Datatable using Read Range Workbook Activity.
Then use the Look Up Datatable Activity to get the matching name value for the hobbies value passed to it.

Let us know if you are facing issues.

Hi there,

Thank you for the answer! Seems like a great solution. I was also looking into LINQ to get the same result. Would you know how I could go about that?

[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

depending on your detail it is to decide if the case is more matching to a where, join, match case.
For further assistance we wuld recommend as mentioned:

@supermanPunch Thanks to the both of you! Here’s what the email format looks like:

Hello,
Thank you for your feedback. Here’s a copy of your answers.

Age: 28
OS: iOS 13
ID: 2023.22
Title: Nightlife
Hobbies: Dancing

The only thing that is relevant in this email is the value after hobbies. In that case, it’s ‘‘dancing’’. There’s an Excel format that has a list of all people and their matched activities as followed:

John Fishing
Malorie Dancing
Peter Gaming

In this case, this email will be assigned to Malorie because she’s responsible for all the feedback regarding ‘‘dancing’’.

I hope this makes more sense. I would preferably like to use LINQ for this, but am unsure of the best way to go about this. Please let me know if you need any more input!

@Nomad ,

For Extracting the value after Hobbies (If not done Already), a regex expression should help like below :

hobbyValue = Regex.Match(EmailBody,"(?<=Hobbies:).*",RegexOptions.IgnoreCase).Value.Trim

Next, Considering the Excel Data provided, not sure if there is a column name used. We can Read the Excel sheet as Datatable, say DT. We could then perform the search and fetch the First value that matches the Hobby in the below way :

Name = DT.AsEnumerable.Where(Function(x)x(1).ToString.ToLower.Equals(hobbyValue.ToLower)).First.Item(0).ToString

Also to note, "email will be assigned" is not explained. So we assume you would only want to retrieve the name value.

Yes this is perfect, thank you!!

1 Like

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