コード例 #1
0
    def extractField(self,aRawColumn):
        #verify field pattern first
        aRawColumn = aRawColumn.replace(" ","") # remove spaces for the column
        
        columnStyleOk = Util.checkColumnNameStyle(aRawColumn)
        field = None
        if(columnStyleOk):
            pipeSignIndex = aRawColumn.index('|')
            firstBracketIndex = aRawColumn.index('(')

            columnName = aRawColumn[pipeSignIndex+1:firstBracketIndex]
            columnType = aRawColumn[firstBracketIndex+1:-1] 
            
            field = MField()
            field.fieldName = columnName
            field.fieldType = columnType
            
            isFieldTypeValid = Util.getDictValue(Rules.dataTypes, columnType, False)
            
            if not isFieldTypeValid:
                raise Exception ("Field type is not valid...")
            
        else:
            # don't throw exception just ignore the column
            #raise Exception("Column name  not valid " + str(aRawColumn))
            None
        
        return field