Extract Cell index which contains specific word

I want to extract a datatable from a web page as “url” and then return the index of the cell in that datatable that contains the word “specific_word”.

datatable:

How can I extract cell index that contains that “specific_word”?
with Assign activity? or other activity?

please let me know…

Hi @hoseongwon

Method 1:

To extract cell index which contains specific word on UiPath, you can use the Lookup Data Table activity which enables you to search for a provided value in a specified DataTable and returns the RowIndex and ColumnName at which it was found.

Method :

Try with this LINQ expression

To get row index

int rowIndex = dt.Rows.IndexOf(dt.AsEnumerable().Where(Function(row) row(0).ToString.Contains("yourSpecificWord")).ToArray()(0))+1

To get column index

int colIndex = dt.Columns.Item("ColumnName").Ordinal+1

Check out this thread

Regards
Gokul

2 Likes

thank you for your kindness.

I am trying with your solution “to get row index”

dt_my_table.rows.IndexOf(dt_my_table.AsEnumerable().where(function(row) row(0).ToString.contains(str_my_keyword)).ToArray()(0))+1

but it failed. It’s failure message is like this.
"errorBC30512 option strict on disallows implicit conversions from ‘integer’ to ‘string’

what did I wrong?

Oh. I assigned int variable to string. I solved the problem with your solution. Thank you So much!!!

I got other problem with your solution during debugging.
“Assign: Index was outside the bounds of the array.”
how can I solve this?

HI @hoseongwon

When you try to access an element in an array that does not exist or is out of range

Example, if you have an array of 5 elements and you try to access the 10th element, you will get this error.

Kindly check the syntax that you have been used in the expression

To fix this error, you need to make sure that your index is within the bounds of the array length.

You can use the Length property of the array to check how many elements it has and avoid using indexes that are greater than or equal to it.

Check out this thread

Regards
Gokul

1 Like

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