Remove leading charachter from a column value of Datatable

I have a data table with column name Column1 which could have value which starts with 0 or not. If starts with 0 I need to remove it.

It’s working with for each activity but it’s slow. Any better option.

Thanks

@anneebeek,

LINQ will be faster than For Each DataTable Row activity. Try this code in Invoke Code activity.

Try
'Create a local copy of the DataTable
Dim localDt As DataTable = io_DataWithZeros.Copy()

localDt.AsEnumerable().ToList().ForEach(Sub(row) row("Column1") = row("Column1").ToString.TrimStart("0"c))

'Assign the modified DataTable back to the original ByRef parameter
io_DataWithZeros= localDt
Catch ex As Exception
	Console.WriteLine(ex.Message)
End try
2 Likes

@anneebeek Attaching sample workflow
Workflow-Sample.xaml (10.1 KB)

1 Like

Hi @anneebeek

You can use Filter datatable activity and provide filter as below.

hope this helps.

1 Like

Thanks. This works faster.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.