Skip to content

Commit 267251d

Browse files
cschloerroll
authored andcommitted
Add preserve_missing_values parameter to field.cast_value (#260)
1 parent f31b270 commit 267251d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tableschema/field.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,15 @@ def descriptor(self):
7979
"""
8080
return self.__descriptor
8181

82-
def cast_value(self, value, constraints=True):
82+
def cast_value(self, value, constraints=True, preserve_missing_values=False):
8383
"""https://github.com/frictionlessdata/tableschema-py#field
8484
"""
8585

8686
# Null value
8787
if value in self.__missing_values:
88+
# If missing_values should be preserved without being cast
89+
if preserve_missing_values:
90+
return value
8891
value = None
8992

9093
# Cast value

0 commit comments

Comments
 (0)