Datatable with Dynamic Column names

Hi,

I would like to compare the 2 data tables. But the issue is in 2nd data table, header values changes dynamically. Like column1 = “Users” but sometimes it will have headers as Column1 names “Users Name”

Due to this for each throws error. Is there any option to compare the datatable with dynamic headers? is it possible to use contains for the headers?

@Palaniyappan

2 Likes

Hi @monish06

While reading datatable using read range untick the headers option so while reading excel files it will not consider the headers

And thus u can compare the datatable easily even if the column name change

Hope it helps you

Regards

Nived N :robot:

Happy Automation :relaxed:

yes i tried, but next time not only the header name changes even the position of the header getting changed.

is there any possible to get the rows(“Column name”) into rows.contains() like that so that it can match the available column name and proceed.

Hi @monish06

Check this

How to get column names of data table to an array?

Hi @monish06

If I can get to know this like how the comparison should be made then the further steps could be streamlined

Is it like comparing one column of dt1 with all columns in dt2
Or
Comparing the entire datatable with another datatable

And if we don’t know the column name or it’s position on what basis we will be finding that…Ok! This is the column needs to be compared

Kindly clarify these

Cheers

Like my first datatable has 5 columns namely Users, Age, DOB, Place.
my second datatable has 5 columns namely
Users, Age, DOB, Place.

Users will sometime change the header name of the second datatable to:
Users name, Age, Place of birth, DOB.

So in order to compare with the second datatable columns is changed due to that it throws error and also some column name position is also getting changed.

My point is, is it possible to compare these two datatables using .contains methods on column headers?

Once I had the same issue. There are 2 solutions:
1.You need to create dictionary (or something else if you want) of possible names and then iterate through columns via “for each” activity and match dict with current col name to find which names are in use this time. Use regex to search more flexible way if possible names have no finite number
2. While you search names you need remember indexes of columns and then operate with indexes not names.

1 Like

Can you provide any example xaml? for reference.

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