Check if row contains string

Hey guys,
maybe someone has an answer:
I have a dataTable column of Strings. I need to check if each of them contains “String2”.
How this IF- expression should look like?
Thanks

2 Likes

Hi
We got two ways to handle this buddy
Like if we know the column name then
row(“columnname”).ToString.Contains(“yourstring”)
Or
If we know only the column index and we don’t know the columnname
That is usually column index will start from 0 for the first column in a datatable similar to that of rows
So we can mention like this
row(Columnindex).ToString.Contains(“yourstring”)
Like
row(1).Tostring.Contains(“yourstring”)
Where the column index 1 denotes B column
So the steps are
—use a excel application scope and pass the file path input
—use read range activity and get the output as a datatable variable of name outer
—use a for each row loop and pass the above variable outfit as input
—inside this for each row loop use a if condition either of this
Any one
row(“columnname”).ToString.Contains(“yourstring”)

Or
row(Columnindex).ToString.Contains(“yourstring”)
And if this condition passes it will go to THEN part of it condition where we can use activities we want
Or it will go to ELSE part where we can have other activities

Simple buddy isn’t it…
Kindly try and let know for any queries or clarification
Cheers @Slavich

1 Like

@Slavich You have loop through each row and use string contains.
CheckStringinDT.xaml (6.9 KB)

2 Likes

Yes it is. Thank you!

1 Like

Very good example.
It helped me a lot for further development.
Thank you!

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