Skip to content

Instantly share code, notes, and snippets.

@jamesktan
Last active November 30, 2015 18:24
Show Gist options
  • Save jamesktan/065985ab784fcf820c1f to your computer and use it in GitHub Desktop.
Save jamesktan/065985ab784fcf820c1f to your computer and use it in GitHub Desktop.
Script that parses out the Timestamp, URL, and port of an IIS6 Server Log.
import os
directory = "D:\INFOWEBAPPSLOGS\W3SVC1618619580\\"
fileList = os.listdir(directory)
for fname in fileList:
filePath = directory + fname
a = open(filePath)
c = a.readlines()
for line in c:
if ("/secretariat/article.xml.asp") in line:
f = open("C:\Users\jtan\OUTPUT.LOG", "a")
lineList = line.split(' ')
lineNew = " ".join(lineList[0:6]) + "\n"
f.write(lineNew)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment