Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # parse-timing-file.py
- # make csv file out of timing file
- from optparse import OptionParser
- parser=OptionParser()
- parser.add_option("-i", "--inputfile", dest="f_in", help="timing file")
- parser.add_option("-o", "--outputfile", dest="f_out", help="csv file")
- (options, args) = parser.parse_args()
- if options.f_in is None or options.f_out is None:
- parser.error("[-] please provide in- and output file names")
- parser.print_usage()
- exit(1)
- print "[*] opening input file: %s" % options.f_in
- fin = open(options.f_in, 'r')
- print "[*] opening output file: %s" % options.f_out
- fout= open(options.f_out, 'w')
- lcount = 1
- while True:
- wline = "" + str(lcount)
- print "[*] writing line %s" % wline
- s=fin.readline().rstrip()
- if len(s)==0:
- break
- wline=wline + "," + s + ","
- wline=wline + fin.readline().rstrip() + "," + fin.readline().rstrip() + "\n"
- fout.write(wline)
- lcount += 1
- fin.close()
- fout.close()
- exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement