compare columns of two unsorted file in python....specific output required -
i have 2 pipe delimited files large data...need compare columns..i column primary key......
eg. one.dat
123|ny|aa|500 569|ny|a|450 777|ok|b|250 899|ok|c|100
two.dat
569|ny|a+|500 777|ok|a|350 899|ok|b|150
output should like:
ny column3 1 ny column4 1 ok column3 2 ok column3 2
it means ny records... column iii has 1 difference matched records..for ok records...column 3 has 2 differennces matched records....
i want join 2 files on column primary key , compare columns.
please me out :)
if files sorted, bits of example show are, can in way similar merge phase of merge sort:
- you start simultaneously @ beginning of 2 files , read row each.
- if primary keys match, compare them , output difference rows want.
- if not, see of them has lesser key , move on next row in file.
- repeat 2 or 3 until you've reached end of 1 of files.
if files aren't sorted, sort them primary key first.
Comments
Post a Comment