saibsk
asked on
comparing two reports
I need to compare two reports. Both the reports contains customer information but in different order. So if I run the diff command gives almost the entire file as difference becuase of difference in the ordering. Can you please suggest a way for comparison?
Long story short, you will need to reformat the data from both reports so that they are (or could be) the same. I like to use awk to rip out and format the data, then use the sort command to put the data in the right order for both files, and then you can use diff to see if things really are different.
For further help, it would be nice if there where a snippet of each file as well as which fields in each snippet where pertinent to the comparison.
For further help, it would be nice if there where a snippet of each file as well as which fields in each snippet where pertinent to the comparison.
Depending on how the files are organized, you might be able to write a perl script that would read both files, and compare based on a unique key, like customer id. If you are interested in this, post a sample of the files.
ASKER
################Checking Data###################
Name: joe Smith
Account: 777333
City: New Jersey
07/13/2009 07/14/2009
MONDAY TUESDAY
Withdrawal: Deposit:
$0.00 $0.00
Name: jack williams
Account: 777343
City: New Jersey
07/13/2009 07/14/2009
MONDAY TUESDAY
Withdrawal: Deposit:
$1110.00 $2220.00
If one report has the data something like this the other report has the same data but the it could be in a different order e.g Jack williams would be first and joe smith second
if i am sorting the data it is not coming out correct. Please advise
Name: joe Smith
Account: 777333
City: New Jersey
07/13/2009 07/14/2009
MONDAY TUESDAY
Withdrawal: Deposit:
$0.00 $0.00
Name: jack williams
Account: 777343
City: New Jersey
07/13/2009 07/14/2009
MONDAY TUESDAY
Withdrawal: Deposit:
$1110.00 $2220.00
If one report has the data something like this the other report has the same data but the it could be in a different order e.g Jack williams would be first and joe smith second
if i am sorting the data it is not coming out correct. Please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
with this type of data, it is better to load data into database and then compare records of both files
ASKER
Hi ozo, Your solution works for me but I have two questions:
what about other lines in the file like the headers?
Additionally suppose one file contains data liek this
MONDAY TUESDAY
and the other file does contain the same info but the data is shifted something like
MONDAY TUESDAY It still gives the line as the difference between the two files.
As long as the data in the lines match i dont want the difference to show becuase of the spaces or change in alignment. Please advise.
what about other lines in the file like the headers?
Additionally suppose one file contains data liek this
MONDAY TUESDAY
and the other file does contain the same info but the data is shifted something like
MONDAY TUESDAY It still gives the line as the difference between the two files.
As long as the data in the lines match i dont want the difference to show becuase of the spaces or change in alignment. Please advise.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You will at least see differing lines, although out of context.
Use sort [filename] > [temp_filename] to sort