# Get a row as a string variable from a data table

**URL:** <https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [February 3, 2019, 10:22pm UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597 "2019-02-03T22:22:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/michaelk/32/97134_2.png) [@MichaelK](https://forum.uipath.com/u/MichaelK)\
**Post date:** [February 3, 2019, 10:22pm UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/1 "2019-02-03T22:22:39Z")

</div>

Hello  
I have a data table stored in a dt variable.  
I need to extract the values of the specific row of this dt (by its index, row(index)) to a string variable Row\_Value.  
The way I can do it now is through the Output DataTable activity, and then splitting the output string by a Newline delimiter. I believe this is not the most effective way to do this simple operation.  
For each row activity is also not good as I need the value of only ONE single specific row, and don’t want to cycle through the whole DataTable.  
Can anyone advise me what are the alternative ways to do it?

---

<div class="post-metadata">

**Author:** ![kunalj](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kunalj/32/101032_2.png) [@kunalj](https://forum.uipath.com/u/kunalj)\
**Post date:** [February 3, 2019, 11:21pm UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/2 "2019-02-03T23:21:05Z")

</div>

Hi @MichaelK

The link below can be helpful in your scenario

> [@Getting a Specific value from Datatable without using For Each loop](https://forum.uipath.com/t/getting-a-specific-value-from-datatable-without-using-for-each-loop/12887/4):
>
> I already found the answer. It took me some trial and error, I’m not sure if this is an efficient way but it is working and most importantly it is a one liner. Of course we can access inside a Datatable using indexes such as myDT.Rows(0).Item(1).ToString, but when using a search criteria such as SELECT inside a DataTable, we can use myDT.Select(“Key=‘Name’”)(0).Item(1).ToString Cheers Everyone!

---

<div class="post-metadata">

**Author:** ![rahatadi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahatadi/32/9191_2.png) [@rahatadi](https://forum.uipath.com/u/rahatadi)\
**Post date:** [February 4, 2019, 2:54am UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/3 "2019-02-04T02:54:58Z")

</div>

@MichaelK

YourDT.rows(rownumber).item(columnnumber)  
Rownumber =rowindex  
Coulmnnunber can be replaced with columnname as well

If you have some fixed rules to select row  
YourDT.select(“columnname =‘yourcondition’”).copytoDatatable

You can use \<,\>, like ,= in select function

---

<div class="post-metadata">

**Author:** ![MichaelK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/michaelk/32/97134_2.png) [@MichaelK](https://forum.uipath.com/u/MichaelK)\
**Post date:** [February 4, 2019, 7:18am UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/4 "2019-02-04T07:18:34Z")

</div>

Thank you very much. It works. I did not know that “item” is a word for a column.

---

<div class="post-metadata">

**Author:** ![rahatadi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahatadi/32/9191_2.png) [@rahatadi](https://forum.uipath.com/u/rahatadi)\
**Post date:** [February 4, 2019, 8:27am UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/5 "2019-02-04T08:27:42Z")

</div>

@MichaelK

Welcome…

🙂

---

<div class="post-metadata">

**Author:** ![MichaelK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/michaelk/32/97134_2.png) [@MichaelK](https://forum.uipath.com/u/MichaelK)\
**Post date:** [February 24, 2019, 11:28pm UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/6 "2019-02-24T23:28:47Z")

</div>

Hi @rahatadi  
This Select feature is very powerful. Thank you for your advice.  
I have 2 questions if you don’t mind:

1. I do YourDT.select(“columnname =‘yourcondition’”).copytoDatatable however the data table and assign the returned value to the NewDT. However in case DT doesn’t have the rows matching ‘yourcondition’ the assign activity throws an error. What is a good way to bypass it ?
2. Where can I read more about the select and other DT functions ? Can you please send me the link to the resources available if any ?

---

<div class="post-metadata">

**Author:** ![rahatadi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahatadi/32/9191_2.png) [@rahatadi](https://forum.uipath.com/u/rahatadi)\
**Post date:** [February 25, 2019, 12:31pm UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/7 "2019-02-25T12:31:00Z")

</div>

@michaelk

1. Put it in try catch block and catch invalid operation or argument exception. Or you can use enumrable methods for same.

2.you can refer this [DataTable Class (System.Data) | Microsoft Learn](https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable?view=netframework-4.7.2)

---

<div class="post-metadata">

**Author:** ![MichaelK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/michaelk/32/97134_2.png) [@MichaelK](https://forum.uipath.com/u/MichaelK)\
**Post date:** [February 25, 2019, 7:24pm UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/8 "2019-02-25T19:24:50Z")

</div>

Thank you @rahatadi  
However I don’t understand how to recover. In the catch block I do 1 second delay and then repeat Append range. However it helps in 50% cases only. In the other 50% it does not.

---

<div class="post-metadata">

**Author:** ![MichaelK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/michaelk/32/97134_2.png) [@MichaelK](https://forum.uipath.com/u/MichaelK)\
**Post date:** [February 26, 2019, 12:08am UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/9 "2019-02-26T00:08:12Z")

</div>

Hi @rahatadi

Please disregard my previous response. It is on a different topic.  
Thank you for advising me on the Try Catch, I will definitely test it.  
However I’m not familiar with the enumerable methods. Please  
advise me the link where I can read about them.  
Thanks for the link to the datatable class.

---

<div class="post-metadata">

**Author:** ![MichaelK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/michaelk/32/97134_2.png) [@MichaelK](https://forum.uipath.com/u/MichaelK)\
**Post date:** [March 10, 2019, 4:23am UTC](https://forum.uipath.com/t/get-a-row-as-a-string-variable-from-a-data-table/92597/10 "2019-03-10T04:23:46Z")

</div>

Hello  
I found that in case the column name contains more than 1 word the Select methos doesn’t work as expected. I tried to put it in single quotes but it did not work either.  
Is there also a way not to use the column names but rather the column indexes ?
