Skip to content

Commit

Permalink
Merge pull request #35 from william-andre/master-pr-wan
Browse files Browse the repository at this point in the history
add support for null values in D, F and L parsing
  • Loading branch information
olemb authored Dec 21, 2020
2 parents 98d52a3 + fe619c5 commit 9617844
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dbfread/field_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def parseD(self, field, data):
try:
return datetime.date(int(data[:4]), int(data[4:6]), int(data[6:8]))
except ValueError:
if data.strip(b' 0') == b'':
if data.strip(b' 0\0') == b'':
# A record containing only spaces and/or zeros is
# a NULL value.
return None
Expand Down Expand Up @@ -119,7 +119,7 @@ def parseL(self, field, data):
return True
elif data in b'FfNn':
return False
elif data in b'? ':
elif data in b'? \0':
return None
else:
# Todo: return something? (But that would be misleading!)
Expand Down Expand Up @@ -162,7 +162,7 @@ def parseN(self, field, data):
Returns int, float or None if the field is empty.
"""
# In some files * is used for padding.
data = data.strip().strip(b'*')
data = data.strip().strip(b'*\0')

try:
return int(data)
Expand Down

0 comments on commit 9617844

Please sign in to comment.