-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbullets_export.py
45 lines (39 loc) · 1.06 KB
/
tbullets_export.py
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
from pyexcel_ods import get_data
def export(data):
data.sort()
while not data[0] or data[0][0] == 0.0:
del data[0]
for row in data[:3]:
del row[7]
del row[6]
del row[5]
del row[4]
del row[3]
del row[2]
del row[1]
del row[0]
for row in data[3:]:
if row:
del row[21]
del row[19]
del row[7]
del row[6]
del row[5]
del row[4]
del row[3]
del row[2]
del row[1]
del row[0]
def tostr(i, v):
if 16<=i<=18:
return str(float(v))
try:
return str(int(v)) if float(v) == int(v) else str(float(v))
except:
return str(v)
with open('TBullets.pck', 'w') as of:
of.write(''.join(r[0]+'\n' for r in data[0:2]))
of.write(''.join((';'.join(tostr(i, v) for i, v in enumerate(r))+';\n') for r in data[2:] if r))
if __name__ == '__main__':
data = get_data("tbullets.ods")['tbullets']
export(data)