Advertisement
0xACAB

parse-timing-file.py

Feb 11th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #!/usr/bin/python
  2. # parse-timing-file.py
  3. # make csv file out of timing file
  4.  
  5. from optparse import OptionParser
  6.  
  7. parser=OptionParser()
  8. parser.add_option("-i", "--inputfile", dest="f_in", help="timing file")
  9. parser.add_option("-o", "--outputfile", dest="f_out", help="csv file")
  10. (options, args) = parser.parse_args()
  11.  
  12. if options.f_in is None or options.f_out is None:
  13.     parser.error("[-] please provide in- and output file names")
  14.     parser.print_usage()
  15.     exit(1)
  16.  
  17. print "[*] opening input file: %s" % options.f_in
  18. fin = open(options.f_in, 'r')
  19. print "[*] opening output file: %s" % options.f_out
  20. fout= open(options.f_out, 'w')
  21. lcount = 1
  22.  
  23. while True:
  24.     wline = "" + str(lcount)
  25.     print "[*] writing line %s" % wline
  26.     s=fin.readline().rstrip()
  27.     if len(s)==0:
  28.         break
  29.     wline=wline + "," + s + ","
  30.     wline=wline + fin.readline().rstrip() + "," + fin.readline().rstrip() + "\n"
  31.     fout.write(wline)
  32.     lcount += 1
  33.  
  34. fin.close()
  35. fout.close()
  36. exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement