Need to remove whitespace from datatable specific column

Hi Guys
Hope you doing good I have excel file and I need to remove extra whitespace from each value can you please help me with linq query.

Hi!

You can use like this:

CurrentRow("ColumnName").ToString.Trim

This will removes the white spaces

Regards,
NaNi

@Aleem_Khan

Try below expression in Invoke Code activity to do that.

InputDT.AsEnumerable().ToList().ForEach(Sub(row) row(“ColumnName”) = row("ColumnName").ToString.Trim)

Note: Create one argument for Invoke Code activity and mention properties as below.

Name - InputDT
Direction - In
Type - DataTable
Value - InputDT

could you please explain this query

I need to remove whitesapce and return it into datatable so that I can use that for my next action.

Hi!

have a view on this:

Regards,
NaNi

Hi Aleem,

Say your original DT is dtData. Take a clone of it say dtCorrected in an LHS of Assign and in the RHS try with below query

(From r in dtData.AsEnumerable
Let ra = r.itemArray.select(Function (x) x.toString.Trim.Replace(" “,”")).ToArray
Select dtCorrected.Rows.Add(ra)
).CopyToDataTable

Thanks

@Aleem_Khan

Above query helps you remove all extra white spaces and write data back to the DataTable. Replace ColumnName with actual column the one you want to remove spaces.