Read .lab files
Simple loader
%%writefile test.lab
#
0 230 f
230 350 o
350 470 n
def _read_lab(filename: str):
ret = []
with open(filename) as file:
for line in file.readlines():
if line.strip() == '':
continue
if line.startswith('#'):
continue
l = line.rstrip().split(' ')
if len(l) != 3:
continue
tmp = {}
tmp['start'] = l[0]
tmp['end'] = l[1]
tmp['phone'] = l[2]
ret.append(tmp)
return ret
_read_lab('test.lab')