How To Get A Datatable With Specified Columns Only In UiPath

While dealing with data table operations, sometimes we might want to retrieve only specific columns from it.

How to do that?

dt_New=dt_Original.DefaultView.toTable(false,”Column1″,”Column2″,…)

Note:
Simply replace the “Column1″,”Column2” and so on with your required Columns


Example

Implementation using UiPath :

Let us implement a workflow which takes a “DataTable” and gives us out the “DataTable with specific columns“.

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 Datatable with Specific Columns 2

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

UiPath Datatable with Specific Columns 3

Step 3:
Drag “Message Box” activity to display the result
(Note: Here we have used LINQ to display the DataTable Instead of Output DataTable

string.join(System.Environment.NewLine, dt_YourDataTable.Rows.Cast(of DataRow).Select(function(row) string.join(“,”,row.ItemArray))))

UiPath Datatable with Specific Columns 4.PNG

Step 3:
Finally!!!

UiPath Datatable with Specific Columns 5.PNG

Click here to download the Source Code…

Hope it has helped you… 

Advertisements

Author: Sharath Raju

Founder@www.ExcelCult.com

Leave a Reply