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!
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:
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!
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.