Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. import re
  2. import sys
  3.  
  4. class event:
  5.     def __init__(self, timestamp, hex, description):
  6.         self.timestamp = timestamp
  7.         self.hex = hex
  8.         self.description = description
  9.  
  10.     def __str__(self):
  11.         return self.timestamp+ ","+ self.hex + "," + self.description
  12.  
  13. eventlog = []
  14.  
  15. filename = sys.argv[1]
  16.  
  17. fh = open(filename)
  18.  
  19. exfilename = filename[0:filename.find(".")] + ".csv"
  20.  
  21.  
  22. full = ""
  23.  
  24.  
  25. for line in fh:
  26.   timestamp = line[line.find("[")+1:line.find(" ")]
  27.   hex = line[line.find(" ")+1:line.find("]")]
  28.   description = line[line.find("] ")+2:line.find("\n")]
  29.   e = event(timestamp,hex,description)
  30.   eventlog.append(e)
  31. fh.close()
  32.  
  33. for each in eventlog:
  34.   if "FFFF" not in each.hex:
  35.     full += str(each) + "\n"
  36.  
  37. print(exfilename)
  38.  
  39. new = open(exfilename,'w')
  40. new.write(full)
  41. new.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement