Skip to content

Instantly share code, notes, and snippets.

@elprup
Created August 27, 2012 05:19
Show Gist options
  • Save elprup/3485791 to your computer and use it in GitHub Desktop.
Save elprup/3485791 to your computer and use it in GitHub Desktop.
hadoop log viewer in Python
import re
mode = r'([A-Z_]*)="([^"]+)"'
vmode = r'\(([^)]+)\)\(([^)]+)\)\(([^)]+)\)'
filename = 's3.txt'
f = open(filename,'r')
lines = f.readlines()
jobinfo = lines[-1]
info = []
for k,v in re.findall(mode, jobinfo):
for kk1, kk2, vv in re.findall(vmode, v):
info.append('%s,%s,%s' % (k, kk1,vv))
for k in sorted(info):
print k
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment