Resources

Knowledge Base

How to Filter a Data Table

Main issue

Many activities have a data table as an output variable, but sometimes we want to filter the information from the data table.

About this workflow

This sample uses a csv file that contains information about people. In the document there are three columns: name, age and city. After applying the filter, we want to see in the output panel only the rows from the csv that respect the filter.

Process automation

1. Read the csv file 

I used an application integration approach by reading the csv file with Read Csv File activity. This activity outputs a datatable.

2. Put into an array all the rows that respect the filter

I defined a string variable and assigned a value to it and then creates an array of datarows. I will need this array because the Select method returns an array of datarows.

For more information regarding the Select method you can check the links below:

 I chose to use an assign activity to filter the datatable. In the left side I put the array that I defined earlier and in the right side I wrote the syntax for the Select method.

3. Iterate through the array

I used a loop to go through the selected rows and then another loop to iterate through the items of the row. Pay attention when you are using a For Each loop to select from the properties panel the correct TypeArgument. In our case the first For Each iterates through an array of datarows so we need to have the datarow as TypeArgument.

4. Display the items from the datarow in the Output Panel

To display something in the output panel, use Write Line activity. Because UiPath is built over Visual Basic .Net you have the entire power of .Net Framework, in the second Write Line activity we will display a new empty line in order to have a better view of each row.