Skip to content

Commit 001ce2c

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

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pyntcloud/io/off.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def read_off(filename):
1212
if "OFF" not in first_line:
1313
raise ValueError("The file does not start with the word OFF")
1414
has_color = "C" in first_line
15+
num_rows = None
1516

1617
# Read header.
1718
for line in f:
@@ -25,6 +26,9 @@ def read_off(filename):
2526
num_rows = n_points + n_faces
2627
break
2728

29+
if num_rows is None:
30+
raise ValueError("The file does not contain a valid header")
31+
2832
# Read remaining lines.
2933
lines = [next(f) for _ in range(num_rows)]
3034

0 commit comments

Comments
 (0)