Is it possible to read the excel which have 2 or more columns with same name?

I am trying to read the excel with same column name. it is showing error?

So, I wanna ask how can I read this kind of excel? is it possible?

@Palaniyappan

Thank you
Aryan

1 Like

You can read it, but without headers property checked. When processing, you should skip 1st row.

its very simple buddy
we can uncheck the ADD HEADERS property in READ RANGE ACTIVITY and get the output with a variable of type datatbale named dt
–now this dt will have default column name as column1, column2,…
and if we want to access any column we can do that only with column index and it starts from 0 for first column like this inside the FOR EACH ROW loop
row(0).ToString
row(1).ToString

Cheers @AryanSingh

@AryanSingh

It is not possible when you try to read with the “Add Headers” property as checked.

@RobertD
@Palaniyappan
@hacky

and if I wanna manipulate some data, but this its column can differ from month to month?
Then?

How can I go about it?

Hope, I am clear!

Thanks
Aryan

2 Likes

@hacky
@Palaniyappan
@RobertD

I think uipath should give us the leeway in reading excel and maintaining the excel even if it contains multiple same name columns!

:thinking:

Thanks
Aryan

@AryanSingh

I guess so. but then data manipulation while referring the particular column would be kinda difficult.

Also, personally I have never came up with the scenario where multiple same name columns were involved.

Lets listen up from others.

@hacky

I agree with you. That’s a valid point! But value’s under it are different!

@AryanSingh

Values under it does not matter.
Because Read Range acknowledge the datatable with respect to Headers.

@hacky

Yeah but we can not say that to the client. :sweat_smile:

Hi @AryanSingh

Do One thing uncheck the AddHeaders property
and use Build Data Table activity and use
for each row in Dt
add data row and pass the values in Array row
Then print the output datatable

Thanks
Ashwin S

2 Likes

@AshwinS2

I am not sure I understand the steps completely!

the reason is if we are accessing the datatable column values and on mentioning a column name which is duplicated as two or more column name, then the compiler will get confused on which column to refer…right…
so thats why its not allowing while retriving itself…and this is one of the reason…there are many reasons behind

Cheers @AryanSingh

1 Like

@Palaniyappan

Yes I understand!

1 Like

Hi @AryanSingh

1What i am trying to say is uncheck the add headers property in read range
2.Use For each row in datatable
3.use add data row and pass the property as Array row as {row(0).ToString}
4 then print the output with Output Datatable

Thanks
Ashwin S

@AryanSingh

EASY APPROACH…

You can read the datatable without headers and then naturally, robot will have column names as “Column-0”, “Column-1”, and so on.

Now, you can use the assign activities to rename the column names as you wish.

Makes sense?

For example, you read the datatable (without headers ) as dtReadRange

Now to replace the column names as you want you can use assign activity as follows:-

dtReadRange.column(“Column-0”).ColumnName = “Name”
dtReadRange.column(“Column-1”).ColumnName=“Age”
dtReadRange.column(“Column-2”).ColumnName=“Place”

This way you have all the columns in the datatables dtReadRange (you can try to write Range and check for verification)

Here, - Name, Age and Place were just examples, you can use any name you want.

I hope client wont problem with this approach. Hehe.

Thanks and Regards,
@hacky

But again if there are similar column names and on taking values from any of those column by referring their column name will be a issue,…right
kindly correct me if i m wrong

@AryanSingh @hacky

@Palaniyappan

Thats a good point.

But then as this question suggests, it was all about reading the excel with same column names.

If he is fine reading without headers and renames with his own column names. It will be fine.
OR
He can give the his own column names in more suggestive(yet unique) way, such as Name1, Name2, Name3 etc

regards,
@hacky

1 Like

@Palaniyappan
@hacky

Yes, And there are so many column names and everytime these values not same, they are dynamic, per month can have different number of transactions. so if I use @hacky 's suggestion, it will be long and gruelling process to rename and from next months it might be correct or not, we cannot say for sure.

Thanks guys, for all the guidance.
Aryan

1 Like

Hello @Palaniyappan what should i do if my column are changing every week or twice a week?