text 18 41 48 Cisco 100 100 -39 -97 Symbol 100 100 -27 -97 18 41 49 Ci

 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
>>> text = '''18:41:48
Cisco 100/100 -39 -97
Symbol 100/100 -27 -97
18:41:49
Cisco 100/100 -37 -97
Symbol 100/100 -27 -97
18:41:49
18:41:49 '''
>>> def f(text):
lines=text.split('\n')
is_res=True
print '\tCisco\tSymbol'
for line in lines:
s=line.split()
if len(s)==1:
if not is_res:
print '%s\t0\t0' % t
t=s[0]
is_res=False;
else:
if s[0]=='Cisco': is_res=True; print '%s\t%s' % (t, s[1]),
elif s[0]=='Symbol': print s[1]
if not is_res:
print '%s\t0\t0' % t
>>> f(text)
Cisco Symbol
18:41:48 100/100 100/100
18:41:49 100/100 100/100
18:41:49 0 0
18:41:49 0 0
>>>