Skip to content
Advertisement

How to check if data’s of two files are matching by checking column wise?

I have two files for eg input.txt and output.txt.

input.txt

JavaScript

output.txt

JavaScript

i have to compare these two files such a way that if first column between two files matches then i have to check for 2nd column and if both matches then it’s okay and if second column doesn’t match then i have to write that data to a file.

that is

if 00000000af16380f is not present in output.txt then i have to write that row in to a file named unmatch.txt.

unmatch.txt:(if address of input.txt doesn’t matches with output.txt)

JavaScript

and if address matches for eg: input.txt and output.txt both have same address then i need to check if thier datas matches. if data is not matching i need to write it in to another file un_data.txt.

un_data.txt

JavaScript

how can i do this?

this is current code:

JavaScript

Advertisement

Answer

Based on the information provided, here is what I came up with:
Code has been commented for further explanation:

JavaScript

OUTPUT:

unmatch.txt

JavaScript


un_data.txt

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement