I'm able to search through a folder to all the version log lines, but I am trying to select the newest version in the list, but I don't know how because the elements of the list contains both characters and numbers.
Below is my code for find and creating a list called matched_lines that contains all the lines that states the version number of the log. I hope to find the newest version from this list created, and compare this newest version with the actual latest version outside of the log. For example, a generated list would consist:
['Version 2.13.1.1', 'Version 2.12.1.0', 'Version 2.10.1.4']
In this example, I would hope to select "Version 2.13.1.1", and compare this with the latest version number the log, for example, "Version 2.14.1.0".
for filename in files:
#print('start parsing... ' + str(datetime.datetime.now()))
matched_line = []
try:
with open(filename, 'r', encoding = 'utf-8') as f:
f = f.readlines()
except:
with open(filename, 'r') as f:
f = f.readlines()
# print('Finished parsing... ' + str(datetime.datetime.now()))
for line in f:
#0strip out \x00 from read content, in case it's encoded differently
line = line.replace('\x00', '')
#regular expressions to fidn the version log lines for each type
RE1 = r'^Version \d.\d+.\d.\d' #Sample regular expression
pattern2 = re.compile('('+RE1+')', re.IGNORECASE)
#for loop that matches all the available version log lines
for match2 in pattern2.finditer(line):
matched_line.append(line)
After finding the newest version in this list, I hope to then compare it with the actual latest version number that may be outside of the folder.