How to convert a DataTable to Dictionary in UiPath
Converting a data table to a dictionary is always a useful method to read the excel and use that in the whole process.
In this post we will see how we can achieve that using a LINQ Expression.
First, we have to create a data table or you can read an excel file and create a data table from there.
Create a datatable by using this Activity : Build Data Table as follows
![](https://rpalearners.com/wp-content/uploads/2021/04/bfile.jpg)
Now create a output for this activity as DT in this example as follows.
![](https://rpalearners.com/wp-content/uploads/2021/04/bfile1.jpg)
Now create a Dictionary variable as shown below:
![](https://rpalearners.com/wp-content/uploads/2021/04/bfile3.jpg)
This will be the main part where we are converting a DataTable to Dictionary using LINQ Expression.
Write the LINQ query as shown below:
![](https://rpalearners.com/wp-content/uploads/2021/04/bfile2.jpg)
This is the Output after you implement everything that is mentioned above
![](https://rpalearners.com/wp-content/uploads/2021/04/bfile4.jpg)
That’s it for this post of converting a data table to a dictionary in UiPath using LINQ Expression.