Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparing two excel Sheets whose columns names vary
#2
Not Solved
Divya:

I can outline a procedure that I believe will work. It involves using dictionaries.

Is there one or a combination of two columns that are unique? A unique value is required to be the key of a dictionary.(Sorry, I do not know if you are familiar with dictionaries. I also like to use the dictionaries in DotNetFactory.)
I am going name the first excel as x, and the second excel as y.
I will assume that in x, column 3 is the same as column 2 in y and the values in these columns are unique. (xcolumn3 holds the same data as ycolumn2, just in a different order.) We will use two dictionaries, dict_x and dict_y.

Code:
pseudocode
keyx = sheetName_x.cells(i,3).value

The values will be everything else.
valx =  sheetName_x.cells(i,1).value &";:"&sheetName_x.cells(i,2).value &";:"&sheetName.cells(i,4).value, etc.
So the dictionary can have key/value added to it.
dict_x.add keyx, valx

Where you will have "fun" is with dict_y.  The dictionary values (columns) need to be in the same order as you used in dict_x.

If excel x columns are (first, last, id, married, numchildren) and if excel y columns are (numchildren, id, last, first, married)
valy = first, last, married, numchildren then
keyy = sheetName_y.cells(i,2).value
valy = sheetName_y.cells(i,4).value &";:"&sheetName_y(i,3).value etc.
After the two dictionaries have been filled, you can compare the key/value of one dictionary to the other dictionary.

I have code for doing this when the columns and rows are in the same order for the two spreadsheets. You can even highlight the rows when the values are not identical.

I hope this makes sense.
Reply
Jump to the post that solved this thread.


Messages In This Thread
RE: Comparing two excel Sheets whose columns names vary - by Parke - 03-26-2014, 12:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare Two ex cel sheets and highlight differences neerukonda9 17 14,000 06-03-2020, 12:04 PM
Last Post: rajrk
  UFT issues with Outsystems dynamically generated Id/names jherron 2 1,346 03-02-2020, 09:33 PM
Last Post: Swishy70
  Identify and Count the columns in the datatable Bhuvana 0 933 12-20-2019, 11:15 PM
Last Post: Bhuvana
  UFT taking different script execution timings while comparing 2 excel files. sudheer 0 2,352 06-26-2015, 03:28 PM
Last Post: sudheer
  Comparing webtable data with weblist and webelements in other webpage arnav 1 5,811 04-18-2014, 10:01 PM
Last Post: Parke

Forum Jump:


Users browsing this thread: 1 Guest(s)