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:
|
try:
|
||||||
N_comment_lines,keyword = f.readline().strip().split(maxsplit=1)
|
N_comment_lines,keyword = f.readline().strip().split(maxsplit=1)
|
||||||
if keyword != 'header':
|
if keyword != 'header':
|
||||||
raise TypeError
|
raise ValueError
|
||||||
else:
|
else:
|
||||||
comments = [f.readline().strip() for i in range(1,int(N_comment_lines))]
|
comments = [f.readline().strip() for i in range(1,int(N_comment_lines))]
|
||||||
labels = f.readline().split()
|
labels = f.readline().split()
|
||||||
except TypeError:
|
except ValueError:
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
comments = []
|
comments = []
|
||||||
line = f.readline().strip()
|
line = f.readline().strip()
|
||||||
|
|
Loading…
Reference in New Issue