Skip to content

Commit 2661456

Browse files
author
Atle Frenvik Sveen
committed
handle wrong values in attrubutes
1 parent 202143c commit 2661456

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

shapefile.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,17 @@ def __record(self):
485485
if value == b(''):
486486
value = 0
487487
elif deci:
488-
value = float(value)
488+
try:
489+
value = float(value)
490+
except ValueError:
491+
#not parseable as float, set to None
492+
value = None
489493
else:
490-
value = int(value)
494+
try:
495+
value = int(value)
496+
except ValueError:
497+
#not parseable as int, set to None
498+
value = None
491499
elif typ == b('D'):
492500
try:
493501
y, m, d = int(value[:4]), int(value[4:6]), int(value[6:8])

0 commit comments

Comments
 (0)