I have to remove a symbol (if exists) from one specific column of a DataTable? Do we have any way to achieve the same without using any loop in UiPath ?
Hey @sishiramishra
"Your_Datatable_name".Rows("rownumber").Item("columnName/columnNumber") = "your new value"
Regardsā¦!!
Aksh
It will replace the value, I have to update.
Eg: All -ve symbols should be removed
Is is just the assign new value give by you to that particular Row and column, Rest regarding to replace ā-ā you have to perform your string manipulation like string.replace or Regex.
"Your_Datatable_name".Rows("rownumber").Item("columnName/columnNumber") = "your existing value".Replace("-","")
Regardsā¦!!
Aksh
@aksh1yadav, I have kind of a similar requirement. Iām looking for a way to convert all values in a datatable column to uppercase without using a loop. Can we do this?
Try below expression.
outputDT = inputDT.AsEnumerable().ToList().ForEach(Sub(row) row("ColumnName") = row("ColumnName").ToString.ToUpper).CopyToDataTable
I tried to write this in an Assign activity but it gives an error saying āExpression does not produce a valueā. Did I miss something?
Welcome to our UiPath community.
Can you show me screenshot of the expression you used here. So that I can check and help you.
see the screenshot of the compiler error. My intention is to write āInvalidā on all cells under the āIssueā column of the datatable
This is what I wrote on the assign activity:
dt_InvoiceNames.AsEnumerable().ToList().ForEach(Sub(row) row(āIssueā) = āInvalidā).CopyToDataTable
Thanks
Hi,
Use the below code in invoke code activity
For Each row As DataRow In in_InputDataTable.Rows
row(āIssueā)=āInvalidā
Next
Thanks and Regards,
Sanjit Pal
Thanks for this. One of the simplest way to do it. I guess, Iāve been to skeptic about not using loops
@lakshman, I got the same error āExpression does not produce a value ā.
@Sanjit_Pal, I think the solution proposed should work. But itās again a for loop exactly similar to For Each Row activity in UiPath.
Thanks,
Tharusha
Yes, the statement is also a for each row but it would not take as much time which is taken by the For Each Activity in uipath. It would take very minimal time
Thanks
Sorry. I forgot to mention one point here.
You need to write expression in Invoke Code activity.
dt_InvoiceNames.AsEnumerable().ToList().ForEach(Sub(row) row(āIssueā) = āInvalidā)
Note: Create one argument for Invoke Code activity and mention properties as below.
Name - dt_InvoiceNames
Direction - In
Type - DataTable
Value - dt_InvoiceNames
Sorry. I forgot to mention one point here.
You need to write expression in Invoke Code activity.
InputDT.AsEnumerable().ToList().ForEach(Sub(row) row(āColumnNameā) = row("ColumnName").ToString.ToUpper)
Note: Create one argument for Invoke Code activity and mention properties as below.
Name - InputDT
Direction - In
Type - DataTable
Value - InputDT
You know that still loops, right? Itās impossible for any method to update a database without looping.