Created
October 13, 2014 11:57
-
-
Save baniol/4237c7da23026873da34 to your computer and use it in GitHub Desktop.
Filter logs files for regexp & uniq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# open('not_found.log','w').writelines([ line for line in open('allLogs.log') if 'not found' in line]) | |
fname = 'allLogs.log' | |
with open(fname) as f: | |
content = f.readlines() | |
new = [line for line in content if 'not found' in line] | |
filtered = [] | |
for line in new: | |
line = re.sub(r'^.*WSLog - ', '', line) | |
filtered.append(line) | |
# print(filtered) | |
open('not_found.log','w').writelines(set(filtered)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment