Assigning new value to duplicate column name then converting the 3rd row as new header

Hi,

I have a datatable type variable that looks like this when written in an Excel:
image

I’d like to do some data table manipulation where row 3 will be the header. However, since there is a duplicate column name, I’m having a hard time figuring it out. I plan to assign new value to column B Class before removing the first two rows and converting the 3rd row as new header. Two of my problems are:

  1. How can I chance the value of the first Class column name?
  2. How to convert the third row as the datatable header?

I’d appreciate your ideas.

Thanks a lot!

@_pjflo

  1. Use find/replace activity and search for class and in replace give what you want to…

  2. Use read range with range as "A3" and give add headers

Cheers

Hi,

The project is using a query to get the data table. So I had to do changes on the data table itself.

@_pjflo

If row 3 and the column location is fixed the use assign with dt.Rows(2)(1) = "NewName"

Then use for loop with dt.Columns and inside use assign with currentitem.ColumnName = dt.Rows(2)(index).ToString index is a variable to be created from for loop properties index

Now use dt = dt.AsEnumerable.Skip(3).CopyToDatatable

cheers

1 Like

Thanks for your help! Appreciate it.

1 Like

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