more robust:
* split(maxsplit=1) will raise ValueError if split into two strings is not possible * int('a') will raise ValueError if 'a' cannot be interpreted as an integer
This commit is contained in:
parent
6fed655500
commit
ed9347e9bd
|
@ -76,11 +76,11 @@ class Table():
|
|||
try:
|
||||
N_comment_lines,keyword = f.readline().strip().split(maxsplit=1)
|
||||
if keyword != 'header':
|
||||
raise TypeError
|
||||
raise ValueError
|
||||
else:
|
||||
comments = [f.readline().strip() for i in range(1,int(N_comment_lines))]
|
||||
labels = f.readline().split()
|
||||
except TypeError:
|
||||
except ValueError:
|
||||
f.seek(0)
|
||||
comments = []
|
||||
line = f.readline().strip()
|
||||
|
|
Loading…
Reference in New Issue