Skip to content

Commit bd7fabb

Browse files
committed
fix: raise error if empty header
1 parent 4be3d13 commit bd7fabb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pyntcloud/io/off.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def read_off(filename):
1313
raise ValueError("The file does not start with the word OFF")
1414
has_color = "C" in first_line
1515

16+
num_rows = None
17+
n_points = None
18+
n_faces = None
19+
1620
# Read header.
1721
for line in f:
1822
if line.startswith("#"):
@@ -25,6 +29,9 @@ def read_off(filename):
2529
num_rows = n_points + n_faces
2630
break
2731

32+
if num_rows is None:
33+
raise ValueError("The file does not contain a valid header")
34+
2835
# Read remaining lines.
2936
lines = [next(f) for _ in range(num_rows)]
3037

0 commit comments

Comments
 (0)