[Solved] How to parse a file matching all the lines for a string and keep track of count?
Open the file and read all lines with open(“file.txt”) as f: lines = f.read().splitlines() Make a list of lines that contain the word “Error” data = [ line.lstrip(‘<‘).rstrip(‘>’).split(‘><‘) for line in lines if ‘Error’ in line ] Get the time and message items from the data list errors = [ { ‘time’ : line[0], ‘message’: … Read more