How to Convert Data from a Column in a DataTable to a List in UiPath

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

my_list = ( 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

Implementation in 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.
image

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

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

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

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

I hope you enjoyed the article.

Happy Automation!!!

1 Like