Using add headers with duplicate column names

Hey all

I have an excel sheet with some duplicate headers - snip is below. An example would be 'AMOUNT_TO_ALLOCATE

So I can’t click ‘add headers’ when I put them in to a datatable.

Please can I ask if there is a ui path solution to this (i.e not change the name of the headers in the excel sheet) as I suspect i’ll come across this more than once in my RPA career!

Thanks everyone
Jordan

yah we can use without enabling ADD HEADERS and we can get the column values by mentioning the column index instead of column name inside the for each row or any activity
like this
dt.Rows(rowindex)(columnindex).tostring -in a assign activity
or inside the for each row loop
row(columnindex).ToString

but ensure that the first row is skipped as it is the headers that we know explicitly
so in assign start from 1 as row index like this
dt.Rows(1)(columnindex).tostring -in a assign activity

and inside the for each row loop use a IF condition to validate like this
Not dt.Rows.IndexOf(row).Equals(0)
if true it will go to THEN part where we can have our process or set of activities we want

Cheers @jordrowley

1 Like

Hi @jordrowley,

use row(0).tostring --> Column 1
use row(1).tostring --> Column 2

if you need the headers use assing with headers name

Headers probably dont change
YourString=1stHeader
YourString=2stHeader

1 Like

Hey @Palaniyappan so in the THEN part of the If (your last sentence), that’s where I could have my ‘add to queue’ activity so it doesn’t add the top row of the data table to the queue (the headers)?

Thanks as always
Jordan

yah exactly
Cheers @jordrowley

Cool, thanks for the help. Nice solution. I will practice with it when I can :slight_smile:
Jordan

1 Like

Cool, thank you for the reply :slight_smile:
Jordan

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