-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.py
More file actions
executable file
·54 lines (38 loc) · 918 Bytes
/
convert.py
File metadata and controls
executable file
·54 lines (38 loc) · 918 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import sys
f = open(sys.argv[1],'r')
sim = bool(int(sys.argv[2]))
for line in f:
if line[0] == "%":
continue
else:
W, H, P = [int(x) for x in line.split()]
break
print(W,H,P)
M = [[] for x in xrange(W)]
zap = 0
for line in f:
c, r, x = line.split()
r = int(r)-1
c = int(c)-1
M[r].append("%s %s" % (str(c+1), x))
zap += 1
if r != c and sim:
M[c].append("%s %s" % (str(r+1), x))
zap += 1
print(zap, float(zap)/(float(H*W))*100.)
fo = open("matrix.txt",'w')
fo.write("%s %s\n" % (str(W), str(H)))
for r in xrange(H):
for x in M[r]:
fo.write("%s\t" % x)
fo.write("0\n")
fo.close()
fo = open("vector.txt",'w')
for x in xrange(H):
fo.write("%s\t" % str((x-H/2)/float(H)))
fo.close()
res = open("res.csv","a")
#res = open("dec.csv","a")
res.write("%s; %s; %.2f%%; " % (sys.argv[1].split('/')[2].split('.')[0], str(W), float(zap)/(float(H*W))*100.) )
res.close();