@@ -498,10 +498,6 @@ def __record(self):
498
498
for (name , typ , size , deci ), value in zip (self .fields , recordContents ):
499
499
if name == 'DeletionFlag' :
500
500
continue
501
- elif not value .strip ():
502
- # why this? better to delete this and leave it up to the field type?
503
- record .append (value )
504
- continue
505
501
elif typ in ("N" ,"F" ):
506
502
# numeric or float: number stored as a string, right justified, and padded with blanks to the width of the field.
507
503
value = value .replace (b ('\0 ' ), b ('' )).strip ()
@@ -535,8 +531,12 @@ def __record(self):
535
531
if value == " " :
536
532
value = None # space means missing or not yet set
537
533
else :
538
- value = (value in b ('YyTt' ) and b ('T' )) or \
539
- (value in b ('NnFf' ) and b ('F' )) or b ('?' )
534
+ if value in b ('YyTt1' ):
535
+ value = True
536
+ elif value in b ('NnFf0' ):
537
+ value = False
538
+ else :
539
+ value = b ('?' )
540
540
else :
541
541
# anything else is forced to string/unicode
542
542
value = u (value )
@@ -1009,6 +1009,12 @@ def poly(self, parts=[], shapeType=POLYGON, partTypes=[]):
1009
1009
1010
1010
def field (self , name , fieldType = "C" , size = "50" , decimal = 0 ):
1011
1011
"""Adds a dbf field descriptor to the shapefile."""
1012
+ if fieldType == "D" :
1013
+ size = "8"
1014
+ decimal = 0
1015
+ elif fieldType == "L" :
1016
+ size = "1"
1017
+ decimal = 0
1012
1018
self .fields .append ((name , fieldType , size , decimal ))
1013
1019
1014
1020
def record (self , * recordList , ** recordDict ):
0 commit comments