Hi, how to check if a string value is available in one column of data table.
Example , i want to search “uipath” is available in my my datatable named, dt1 in column “Name”
The column in which i want to search has comma and space separated values like
“Name”
uipath, automationanwhere, blueprism
I want to search in the column “Name” of above dt1 table that my variable “uipath” is available or not
hi @Srini84 , you are using for each row and checking like row(“Name”).ToString = StrVariable
But buddy i dont want to use for each row because my variable is already coming from for each row which i want to match in another datatable.
I tried this query
DT1.AsEnumerable.Select(function® r(“Name”).ToString.Contains(“+StrVariable+”)).Contains(true)
But this doesnt work in this scenario as the coumns in my DT1 has comma separated values
I want the bot to search whether the StrVariable (a string variable) is available in my specific column or not
@ksrinu070184
yeah actually, that StrVariable is a variable coming from another activity therefore i was calling like this
The thing is with Linq query i cannot search and match if the datatable has comma separated values
otherwise its working fine
See this , i want to search in this column whether “uipath” is available or not
Any idea?
@rajat_dhammi
then we can use following:
dtData.AsEnumerable.Any(Function ( r )r(“Name”).toString.Split({“,”}, StringSplitOptions.RemoveEmptyEntries).Contains(“uipath”))
and do use the contains from array checking for uipath as a contained item within the array Filter Data Table.xaml (6.3 KB)
@Srini84 sorry buddy, that doesnt work as already mentioned i have comma separated values in my column in dt1. The above query matches only with one value.
@ppr Thanks buddy, I do not understand your last line
But the query is working fine
I will test with few sample and mark the solution later
Thanks again
in general it splits the string into a string array, split char is the comma
from the array the contains method looks if a particular string is an item within the array or not
@ppr
Thank you, can you please explain this to me, so that i can properly use this.
I didnt understand “StringComparison.InvariantCultureIgnoreCase” !!