I would like to compare two set of result files executed at two different intervals (Files names remains same) which are placed in two different folders by ignoring differences in header part(lets say first 40 lines). please share if anyone does have python program for it.
Input: directory 1 ( x no of files ) directory 2 ( y no of files )
output: Total number of same files; Total number of files having differences
Thank you.
Finally below code serve the purpose.
import os
import os.path
import sys
arr= os.listdir()
arr.sort()
FO = open('Log_Out_Res.txt', 'w')
for file in arr:
if file.endswith('.res'):
fopen= open(file)
# loop throgh each line in the file till get the desired string and extract the version
for line in fopen:
lstrip = line.strip()
if lstrip.startswith('Test File Version:'):
try:
lsplit= lstrip.split()
print(file, "\n Test File Version:",lsplit[3])
FO.writelines(file + ':\n')
FO.writelines(lsplit[3])
FO.writelines('\n')
except:
break
if lstrip.startswith('Result File %version:'):
try:
linesplit= lstrip.split()
print(" Res File Version:",linesplit[3])
FO.writelines('Res File Version:'+linesplit[3])
FO.writelines('\n')
except:
break
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.