How to trim whitespaces from column names in datatable

Hi @Dr_Raza_Abidi_PhD ,

If possible could you pls share your work flow. thanks.

@kirankumar.mahanthi1 : Here is the screenshots:

@Jobin_Joy : Yes still facing the issue

Could you pls mention which activity it is throwing the mentioned error to troubleshoot to further. thanks.

For Each Activity is throwing exception where I am removing whitespaces from the headers of columns. Thanks,

Hi @Dr_Raza_Abidi_PhD

Can you please debug the code little more deeper? the code is working for me,

image


image

Thank you.

@Jobin_Joy : Pl. find below the screenshot: In my excel file, there is a column highlighted in yellow, throwing an exception. Pl. guide what to do?? Many thanks,

Hi @Dr_Raza_Abidi_PhD

It’s a duplicate column. Kindly make columns as unique one in the DataTable.

Thank you.

2 Likes

Thanks a lot @Jobin_Joy : I really appreciate your support. Many thanks,

But could you please tell me that the excel file which I am using in UiPath is coming from some utility and I could not want to manually trace the duplication of headers. As, I removed the whitespace so, it corelates with other column with the same name and threw an exception. The same column does not have any space So, how to handle this situation in UiPath? Thanks,

As a quick something I can suggest is, while you are looping through each columns in the DataTable alone with the Trim, append some index to identify the column uniquely.

So we won’t get any duplicates.

Example:

LHS:
Col.ColumnName
RHS:
Col.ColumnName.Trim.ToString+LoopIndex.ToString.

Note: LoopIndex variable will be incrementing based on the number of columns in the DataTable.

Thank you

1 Like

Alright, would you mind debug it and send me a screenshot of your local variables (in local pannel) + the activity highlighted in red so I would help better ?

@Jobin_Joy : Thanks for your swift response.

@Hiba_B : Thank you very much issue is resolved now but I have 2 more questions:

  1. Could you please tell me that the excel file which I am using in UiPath is coming from some utility and I could not want to manually trace the duplication of headers. As, I removed the whitespace so, it corelates with other column with the same name and threw an exception. The same column does not have any space So, how to handle this situation in UiPath?

  2. How can we remove the whitespaces from each row each cell if any? Suggest me like column headers.

Many Thanks,

@Jobin_Joy : This issue is resolved but Pl. see the next error.

There is no column present in the data table with that name. It could be a spelling mistake as well. Kindly check.

1 Like

@Jobin_Joy : You were absolutely right. Thanks for your great support.

1 Like

Could you please mark the post as ‘Solution’ if the issue is solved so that it will be helpful for others as well?

Thank you.

@Jobin_Joy : Yes, Indeed, I am trying to mark the post as ‘Solution’ but there is no Solution option available at my wall. I think I used the ongoing discussion that’s why not appearing at my wall.

Hi @Dr_Raza_Abidi_PhD

Got it. This thread was initiated by @jamnanin so he can only mark the respective post as solution.

Going forward please create separate topic/issue in the forum. It will be easy to manage.

Thank you. Happy Automation :slight_smile:

@Jobin_Joy : I am really sorry, I have thoroughly tried to mark this post as solution but could not do so. But, I have categorially tried to give you credit as much as possible at discussion.

Many thanks, :slight_smile: :slight_smile:

2 Likes