How to read value of individual cells from datatable


#1

How do I read an individual value from a row and column in a datatable ?

I know I can do for each row and then get item … that’s too cumbersome

I need to simply say x = datatable (row, col)


#2

Hey @bdavidov

You can try this way:

“Datatablename”.Rows(“rownumber”).Item(“columnName/columnNumber”)

Regards…!!
Aksh


#3

Perfect … Thanks


#4

Thanks … How do I get the number of rows and columns in a datatable?


#5

DATABLE ROWS COUNT = Datablename.Rows.Count

Datable coulmn count = Datablename.Columns.Count

Regards…!!
Aksh


#6

Hi,
I am new to UIPath. I am trying to use the expression below as you suggested for getting 2nd row and 0th column. But it pops up an error saying object to string conversion is not possible. Can you tell me what wrong I am doing?
ExtractDataTable.Rows(2).Item(0)

Thanks


#7

Hi @shivnagsudhakar,

Convert.ToString(ExtractDataTable.Rows(RowNumber)("ColumnName"))
or
Convert.ToString(ExtractDataTable.Rows(RowNumber)(ColumnIndex))

If you are using For each row activity
To get some value from the data row.
Convert.ToString(row("ColumnName"))
Or
Convert.ToString(row(ColumnIndex))

ColumnIndex , RowNumber->integer value
ColumnName->String value

Regards,
Arivu


#8

Hey @shivnagsudhakar

I just wanna know where you are using this expression ? in a writeline to write it on console for debugging purpose?

or assigning into a variable? - if so what datatype of variable ?

Regards…!!
Aksh


#9

I am new to Uipath and I have a situation like I have a table of data (only one column). I need to check for a particular string value in the rows in the table. I am using “for each item”. Inside that how do I do a comparison with a string for each item in the row of the table.
I tried “.contains” - it gave me an error “Message box : Table doesn’t have a primary key.”

row.equals inside a “forEach Data table” work?


#10

Use Get Row Item activity store the value of the column in a variable the you can use your condition to work upon. See attached sample

Main.xaml (8.7 KB)


#11

Thank you so much for the reply. My intention is to find a particular row and click on that (it is a hyperlink). I tried with 'find children" but it is giving me compile error after i indicate the first row in the screen in “Find Children” activity
image

OR

image