Get Index of Table Records via Table Extraction

Hi there,

I am using Table Extraction to scrape Data from tables in a browser page. How can I get the index of the rows that I extracted data from? I want to store the index in a data table variable for later use.

Best regards
Robert

1 Like

Hello @Robert_Komorowsky ,

you can use DataTable.Rows.Count.ToString to get the number of rows and
ExcelTable.Columns.Count.ToString to get the column count

Hi

If you want to know the count of rows

int_count = dt.Rows.Count

Where if you want to known IndexOf last row in datatable

It’s same, just minus 1

index_dt = dt.Rows.Count-1

Reason is count starts from 1
Index starts from 0 for first row

And finally if you want to know for each row inside a loop say FOR EACH ROW Activity then mention like this to get the current row index

indexvalue = Dt.Rows.IndexOf(CurrentRow)

Cheers @Robert_Komorowsky

if you iterate the table using for each row, you can set a variable in the index property, this variable will equal the index of the current row

you can try this custom activity

Hi, thank you for your quick answer. However I don’t want the row indexes of the data table output, I want the activity Extract Data Table to store the index of the rows that I scraped from the webpage in a variable called ExtractTableData. For example if I scrape the second, third and fifth row, this variable shall contain rows with the numbers 2,3 and 5. Ist this possible?

We won’t be able to add that from data scrapping wizard
But May be you can scrape the entire table with data scrapping
Then add a datacolumn atlast using add datacolumn

Have the rowindex assigned in that column for each row using for each row

Then get the row you want do that corresponding row index will be there in that last newly added column

Cheers @Robert_Komorowsky

Thank you, it worked! I scraped all the numbers on the page, stored it in a variable and added a column with the index using the custom activity “Append Row Number Column to Data Table”. After that I filtered it using “Filter Data Table” so that only the index numbers I needed remain.

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