Remove Spaces From Entire DataTable Without Loop

I want to remove spaces from a DataTable without using a loop. Can anyone help with that?

Example:

  • Input: [33,11.1 2]
  • Output: [33,11.12]

Thanks in advance!

Hi @madhabhazra0,

try with this LINQ:

dt.AsEnumerable().Select(Function(row) dt.Clone.LoadDataRow(row.ItemArray.Select(Function(field) field.ToString().Replace(" ", "")).ToArray(), False)).CopyToDataTable()

Thanks

Use invoke code like shown below :

dt.AsEnumerable.ToList().ForEach(Sub(r)
r(“col1”)=r(“col1”).ToString.Replace(" “,”")
End Sub
)

The image depicts a workflow process in a programming environment that reads data from an Excel file (data.xlsx), modifies it by removing spaces from a specified column, and writes the updated data to another Excel file (result.xlsx). (Captioned by AI)

Thanks for your help @Manisha_Ravindra

1 Like

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