Logo Search packages:      
Sourcecode: relational version File versions  Download package

def relational::relation::relation::projection (   self,
  attributes 
)

Projection operator, takes many parameters, for each field to use.
Can also use a single parameter with a list.
Will delete duplicate items
If an empty list or no parameters are provided, returns None

Definition at line 140 of file relation.py.

00140                                      :
        '''Projection operator, takes many parameters, for each field to use.
        Can also use a single parameter with a list.
        Will delete duplicate items
        If an empty list or no parameters are provided, returns None'''    
        #Parameters are supplied in a list, instead with multiple parameters
        if isinstance(attributes[0],list):
            attributes=attributes[0]
        
        #Avoiding duplicated attributes
        attributes1=[]
        for i in attributes:
            if i not in attributes1:
                attributes1.append(i)
        attributes=attributes1
        
        #If source and dest has the same number of attributes, we are just rearranging
        #so we won't need to check for duplicated entries
        attributes_same_count=len(attributes)==len(self.header.attributes)
        
        ids=self.header.getAttributesId(attributes)
        
        if len(ids)==0:
            return None
        newt=relation()
        #Create the header
        h=[]
        for i in ids:
            h.append(self.header.attributes[i])
        newt.header=header(h)
        
        #Create the body
        for i in self.content:
            row=[]
            for j in ids:
                row.append(i[j])
            if attributes_same_count or row not in newt.content:
                newt.content.append(row)
        return newt
    
    def rename(self,params):


Generated by  Doxygen 1.6.0   Back to index