Trim Column Name in Data Table

This seems very easy but I’m having a hard time how to trim the column names in my datatable.

First I’m reading the excel file and saves it to my dt variable

image

Then I’m assigning each column names in a variable

image

image

Now, I’m having an error because it’s looking for “Customer Name” but in my reference excel file the column name look like this " Customer Name " with extra spaces.

Hi @Shoji

You can do this process after Read Range Excel activity

For Each col In dtData.Columns
    Assign
        To: col.ColumnName
        Value: col.ColumnName.Trim()

This will trim all the column names which will have spaces and outside For Each loop you can use the assign activities that you have used.

Regards

Hello @Parvathy Thank you for commenting, sorry i don’t understand how to do it. I can’t find For Each Col Activity

Value to save: CurrentRow.ToString.Trim

dtName is datatable data type and I’m getting error since I need to convert it to string before I can use trim function.

You can find For Each Loop @Shoji

Regards

If possible share your excel file I will help you with flow and your required output too @Shoji

So this is my reference excel

image

and this is my destination excel

image

Final Output:

image

What I’m doing is to copy the ID and Name to the destination excel in column Customer Name and Customer ID. I already did this part. The only problem is how to trim extra space in my reference excel column name. Since if there are extra spaces in the reference excel I’m getting an error.

Hi @Shoji

The below workflow will trim the spaces in Destination.xlsx file and copy the data from referecne file to destination file.

Check the below workflow:

Destination.xlsx (7.9 KB)
Reference.xlsx (8.3 KB)
Sequence49.xaml (10.2 KB)

FLOW:

Regards

1 Like

thank you so much, this is working perfectly!

1 Like

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