-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathunique_frames.py
More file actions
39 lines (31 loc) · 822 Bytes
/
unique_frames.py
File metadata and controls
39 lines (31 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys, getopt
from SFF import SFFMessage
verbose = True
outputfile = ""
optlist, args = getopt.getopt(sys.argv[1:], ':o:')
if(len(args) < 1):
print "Usage: %s [options] <inputfile>"
print "options:"
print " -o <output file>"
sys.exit(1)
for o,a in optlist:
if o == "-o":
outputfile = a
inputfile = args[0]
fp = open(inputfile, "r")
unique_msgs = []
total = 0
for line in fp:
msg = SFFMessage(line)
total = total + 1
if not msg in unique_msgs:
unique_msgs.append(msg)
fp.close()
print "File had %d lines and %d were unique" % (total, len(unique_msgs))
if(outputfile != ""):
fp = open(outputfile, "w")
for msg in unique_msgs:
print str(msg)
if(outputfile != ""):
fp.write(str(msg) + '\n')
fp.close()