1)Can you please explain the difference between DataTable.select() and filter Data table activity ? When to prefer each and what is more efficient?, as of now I know one difference i found is return type.It would be great if you attach workflows for corresponding
2)And also how to use Datatable.select type for string type of columns in data table
I have given like this
getting issue
Iām probably not the best to answer since I have not used the Filter Data Table all that much but have looked at it.
The problem I have with the activity is that you cannot verify and convert values during your condition phases. Like if you wanted to make sure the value is compared as a double, you couldnāt simply place in some syntax to say: If(IsNumeric(row(0).ToString.Trim),CDbl(row(0).ToString.Trim,0) = value
Another problem I have with it is that you can only output to a DataTable, so if you want to process or update certain rows while keeping the original data table, you canāt really do that.
So,
Iād say the benefit you get from using .Select() is that you can be more flexible in what you are trying to do.
However, I still prefer the lambda method using .Where() for filtering data, and the coding is lot easier to understand⦠atleast to me. It accomplishes the same as using .Select() for filtering, but if you want to use all the vb.net methods like .Contains, .StartsWith, et cetera itās fairly simple to do so whereas with the .Select() method for filtering you need to use different syntax. EDIT: Ideally, I would want an activity that is flexible like that where you can output to an array of rows or new data table, and also am able to place vb.net coding embedded in the activity on both sides of the comparison⦠or maybe there is a better way to make it user-friendly that can check if the value is a number and convert, etc.
The āCannot find columnā error is most likely happening because your data table was not read in with Column Headers or the Header does not exist. I would check the Read Range or Read CSV and make sure AddHeaders is checked. Also, using Output Data Table you can output the table to a message box to verify that the headers are there correctly.
Datatable.Select() is not an activity. It is a part of .net framework and returns an array of DataRow objects. It can used in any version of UiPath. While Filter Data Table is activity of UiPath and it is available starting with UiPath version v2018.2.x and its output is DataTable.
Filter Data Table activity works very well with STRING type data.
If you use Filter Data Table activity then you cannot play with type conversions. Also if you want to filter using conditions on multiple columns that too of different type, the output will be not the expected one. For example, you want to filter the data from excel/csv with condition like:
Age >30 and Gender = āMALEā and Height >5.5
For this situation to achieve this you have to use multiple Filter Data Table activity, one after another in a sequence
Instead, a simple way is to
Use Excel Application Scope
Use Read Range activity
Use Assign activity,
var_customDT = var_DT_client126.Select("Age > 30 AND Gender = āMALEā AND Height > " + var_height).CopyToDataTable
Note : var_DT_client126 is the name of my data table and var_height is a variable holding height value and var_customDT is the variable that will hold the output of select statement & its type is DataTable
So, as you can notice in a single line we are able to filter the complete data
what would be the expression if all the condition are provided using different argument.
I am getting error using this
var_customDT = var_DT_client126.Select(āAge >ā +in_age+" AND Gender =" +in_gender+" AND Height > " + var_height)
When using Select, the return value will be DataRow(), not DataTable
To convert to DataTable, you have to use CopyToDataTable, but the library of this method cannot be imported via Studio. you have to open the xaml and edit manual
I am trying to filter a data table by date and I am trying to do it the way you explained. however, I am gattingan error which says āAssign: Syntax error: Missing operand after ā00ā operator.ā