How To Put Data From A Column Of DataTable To List – In UiPath

While performing automation, we might be required to take the values from a particular column and then convert it to list so that we can perform further actions or decision flows.

Let us see how to do it in UiPath?

_myList = ( From row in dt_Sample.AsEnumerable() Select Convert.Tostring(row(“ColumnName”)) ).ToList()

Note:
1. ColumnName is the specific column name which you want to convert to list
2._myList is the variable containing your values


Example

Implementation using UiPath :

Let us implement a workflow which takes a sample data table as input and converts particular Column values into a list of string.

Step 1:
Drag “Build Data Table” activity into the design panel and populate it with some sample data.

UiPath Datatable with Specific Columns 1

UiPath Reverse a Datatable 2

Step 2:
Drag “Assign” activity into the design panel and fill it with above-mentioned code.

uiPath Convert column values into a list 1.png

Step 3:
Drag “For Each” activity into the design panel and pass the above “_myList” variable to it.

uiPath Convert column values into a list 2.PNG

Step 4:
Drag “Message Box” activity into the For Each activity and pass the “item” value into it.

uiPath Convert column values into a list 3.PNG

Step 5:
Finally, let’s run the project.
Now, we can see all the values in the columns being displayed.

uiPath Convert column values into a list 4

Click here to download the Source Code…

Hope it has helped you… 

 

 

 

 

 

Advertisements

Author: Sharath Raju

Founder@www.ExcelCult.com

Leave a Reply