0

I have two .txt files. How would I compare them, find and print the difference(s) in a new file?

My files are like:

set  
FDN : "NetworkElement=RNC23,CmNodeHeartbeatSupervision=1"  
active : true

set  
FDN : "NetworkElement=RNC23,FmAlarmSupervision=1"  
active : true  
automaticSynchronization : true  
failoverCount : 9  
heartbeatinterval : 100  

set  
FDN : "NetworkElement=RNC23,InventorySupervision=1"  
active : false  
doInventorySync : false  
inventoryType : LICENSE  

I need to process them in batches rather line by line.

Syncrossus
  • 570
  • 3
  • 17
  • 1
    What have you tried so far to solve your problem? https://stackoverflow.com/help/how-to-ask – Adam Jaamour Apr 13 '18 at 07:49
  • Do you just need to see the differences or do you need to process them? – Maaaaa Apr 13 '18 at 07:50
  • 1
    Please provide details in full e.g 1) content of both files named separate 2) do you want to compare each file with one reference file 3) which file is your reference file – toheedNiaz Apr 13 '18 at 07:51
  • you can read complete files and can split by `set`. – Harsha Biyani Apr 13 '18 at 07:51
  • @toheedNiaz there will be 2 sets of files having this format. filenames would be same. i need to find the difference in the files with respect to FDN. If the FDN: "value" matches with the other file, nothing is to be done. If we find a new FDN, then whole for the its batch, starting from set to the end of its batch, needs to be written to a new file. If the FDN exists for the other file, then we need to compare the underlining child attributes. if the attributes are difference again the whole batch needs to be written. – Nabarko Roy Apr 13 '18 at 09:19

1 Answers1

1

difflib probably covers your use case.

Syncrossus
  • 570
  • 3
  • 17