Trim datatable column with regular expression

Hi,
i have a datatable and i want to trim firtst column without use for each.
It’s possibile to use a regex like this?
dt.AsEnumerable.Where(Function(x) x(“clolum1”).ToString.Trim)…?

Thanks

Have a look at following Blog for the different options for updating a data column value:

How to Update Data Column Values of a Data Table | Community Blog

still, we would recommend doing the trim within a for each activity and and a trim method

i can’t use for each beacause i have a large excel file.

Thanks

this will not be a blocker, however in the Blog you will get presented also the other options

i need help to write a LINQ statement to trim colum.

Hi!

You can use do it like this:

First clone your dt to another one in assign activity:
dtClonedDataTable = dtOriginalDataTable.Clone

And then assuming you have 3 columns column1, column2 and column3 use assign:
dtOriginalDataTable = dtOriginalDataTable.AsEnumerable.Select(Function(x) dtClonedDataTable.LoadDataRow(New Object() {x(“column1”).ToString.Trim, x(“column2”), x(“column3”)}, False)).CopyToDataTable

Hope this works for you!

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