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…
Gokul001
(Gokul Balaji)
March 13, 2023, 7:11am
2
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
Thank you! I’ve did that using For Each loop with Lookup Data Table activity inside it.
In my case: List variable contains SAP symbol, and I look for correlated system name in data table.
You only need to change the names and indexes of columns where to look for data.
Feel free to use this workflow in your projects
correlated_values.xaml (8.8 KB)
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?
Gokul001
(Gokul Balaji)
March 13, 2023, 8:35am
6
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
Hi All,
I am using below code. I wanted to extract either order ID or invoice ID or sometimes both from an .xml file. But it is giving below error:
Assign: Index was outside the bounds of the array.
If anybody can help??
Attaching all relevant document…plz help
New…xaml (19.4 KB)
Data used here:
Data.zip (3.7 KB)
P.S. Run the code u will see the error
Regards
Gokul
1 Like
system
(system)
Closed
March 16, 2023, 8:35am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.