0

I have two text files a.txt that contains data like
abcd = 4.0
def =2.0
jkl= 8.0
and b.txt which has similar data
abcd = 6.0
dfg = 2.0
jkl = 8.0

i want two compare and print the following points in a new text file

1.the names first, if they match the values they hold are matching or not
2. the names that are not matching

4
Contributors
4
Replies
26
Views
4 Years
Discussion Span
Last Post by raicabogdan
0

You could read the first file in and save the data in a hash (using the name as key and point as value). While you read the second file in, check if the key exists in the hash. If exists, compare the value which should be satisfied your #1. If not exists, it is satisfied your #2.

0

I'm not able to separate the data.. the example i gave is a small one only.. originally I have log data that has more than 2000 over lines of data

0

Hi Anirudh1,
Please can you show us what you have been able to do.
All you need do is use open function, read in the first file into an hash and then read in the second file and compare, just like Taywin had previously mentioned.
The lenght of your file had nothing to do with the code you have not presented.
Atleast use the few lines of dataset you presented here.

0

Can you confirm if if the names = values are unique? For example, does the name repeat itself? Do you need to store it twice or more if it is found?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.