-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtextable.py
More file actions
executable file
·52 lines (43 loc) · 1.1 KB
/
textable.py
File metadata and controls
executable file
·52 lines (43 loc) · 1.1 KB
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
#!/usr/bin/env python
import sys
mode = None
options = []
for opt in sys.argv:
if opt == '-skip':
if mode != None:
print('bad argument')
quit()
options.append(('skip',))
elif opt == '-si':
if mode == None:
mode = 'si'
else:
print('bad argument')
quit()
elif opt == '-text':
if mode != None:
print('bad argument')
quit()
options.append(('text',))
else:
if mode == 'si':
options.append(('si', opt))
mode = None
else:
infile = open(opt)
for ln in infile:
ln = ln.lstrip().rstrip()
tok = ln.split(',')
texln = ''
for (t, op) in zip(tok, options):
if op[0] == 'text':
texln = texln + t
elif op[0] == 'si':
texln = texln + '\\SI{' + t + '}{' + op[1] + '}'
elif op[0] == 'skip':
continue
else:
print('bad option: ' + op[0])
texln = texln + ' & '
texln = texln[:texln.rfind('& ')] + '\\\\'
print(texln)