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

def relational::relation::relation::save (   self,
  filename,
  comma_separated = True 
)

Saves the relation in a file. By default will save using the csv
format as defined in RFC4180, but setting comma_separated to False,
it will use the old format with space separated values.
The old format is deprecated since it doesn't permit fields
with spaces, you should avoid using it.

Definition at line 62 of file relation.py.

00062                                                 :
        '''Saves the relation in a file. By default will save using the csv
        format as defined in RFC4180, but setting comma_separated to False,
        it will use the old format with space separated values.
        The old format is deprecated since it doesn't permit fields
        with spaces, you should avoid using it.'''
        
        fp=file(filename,'w') #Opening file in write mode
        if comma_separated: #writing csv
            writer=csv.writer(fp) #Creating csv writer
            
            #It wants an iterable containing iterables
            head=[]
            head.append(self.header.attributes)
            writer.writerows(head)
            
            #Writing content, already in the correct format
            writer.writerows(self.content)
        else: #Writing in the old, deprecated, format
            res=""
            res+=" ".join(self.header.attributes)
            
            for r in self.content:
                res+="\n"
                res+=" ".join(r)
            fp.write(res)
        fp.close() #Closing file
    def rearrange(self,other):


Generated by  Doxygen 1.6.0   Back to index