def __dbfHeader(self):
        """Writes the dbf header and field descriptors."""
        f = self.__getFileObj(self.dbf)
        f.seek(0)
        version = 3
        year, month, day = time.localtime()[:3]
        year -= 1900
        # Remove deletion flag placeholder from fields
        for field in self.fields:
            if field[0].startswith("Deletion"):
                self.fields.remove(field)
        numRecs = len(self.records)
        numFields = len(self.fields)
        headerLength = numFields * 32 + 33
        recordLength = sum([int(field[2]) for field in self.fields]) + 1
        header = pack('<BBBBLHH20x', version, year, month, day, numRecs,
                headerLength, recordLength)
        f.write(header)
        # Field descriptors
        for field in self.fields:
            name, fieldType, size, decimal = field
            name = b(name)
            name = name.replace(b(' '), b('_'))
            name = name.ljust(11).replace(b(' '), b('\x00'))
            fieldType = b(fieldType)
            size = int(size)
            fld = pack('<11sc4xBB14x', name, fieldType, size, decimal)
            f.write(fld)
        # Terminator
        f.write(b('\r'))
def __dbfHeader ( self ) : f = self . __getFileObj ( self . dbf ) f . seek ( 0 ) version = 3 year , month , day = time . localtime ( ) [ : 3 ] year -= 1900 for field in self . fields : if field [ 0 ] . startswith ( "Deletion" ) : self . fields . remove ( field ) numRecs = len ( self . records ) numFields = len ( self . fields ) headerLength = numFields * 32 + 33 recordLength = sum ( [ int ( field [ 2 ] ) for field in self . fields ] ) + 1 header = pack ( '<BBBBLHH20x' , version , year , month , day , numRecs , headerLength , recordLength ) f . write ( header ) for field in self . fields : name , fieldType , size , decimal = field name = b ( name ) name = name . replace ( b ( ' ' ) , b ( '_' ) ) name = name . ljust ( 11 ) . replace ( b ( ' ' ) , b ( '\x00' ) ) fieldType = b ( fieldType ) size = int ( size ) fld = pack ( '<11sc4xBB14x' , name , fieldType , size , decimal ) f . write ( fld ) f . write ( b ( '\r' ) )
Writes the dbf header and field descriptors.