PEATDB/Base.py
def importDict(self, importdata, namefield='name', overwrite=True):
        """Import a list of dicts, each one is a record"""
        if len(importdata) == 0:
            return        
        fields = importdata[0].keys()
        if not namefield in fields:
            print 'no such field for keyname field'
            namefield = fields[0]            
        if namefield == 'name': fields.remove(namefield)
        for f in fields:
            if f not in self.meta.staticfields:
                self.addField(f, 'text')
        for d in importdata:
            name = d[namefield]
            self.add(name, overwrite=False)
            kys = d.keys()
            for f in fields:
                if not f in kys: continue
                try:
                    self.data[name][f] = float(d[f])
                except:
                    self.data[name][f] = d[f]
        return
Import a list of dicts, each one is a record
Import a list of dicts, each one is a record
Import a list of dicts each one is a record
def importDict(self, importdata, namefield='name', overwrite=True):
        if len(importdata) == 0:
            return        
        fields = importdata[0].keys()
        if not namefield in fields:
            print 'no such field for keyname field'
            namefield = fields[0]            
        if namefield == 'name': fields.remove(namefield)
        for f in fields:
            if f not in self.meta.staticfields:
                self.addField(f, 'text')
        for d in importdata:
            name = d[namefield]
            self.add(name, overwrite=False)
            kys = d.keys()
            for f in fields:
                if not f in kys: continue
                try:
                    self.data[name][f] = float(d[f])
                except:
                    self.data[name][f] = d[f]
        return
def importDict ( self , importdata , namefield = 'name' , overwrite = True ) : if len ( importdata ) == 0 : return fields = importdata [ 0 ] . keys ( ) if not namefield in fields : print 'no such field for keyname field' namefield = fields [ 0 ] if namefield == 'name' : fields . remove ( namefield ) for f in fields : if f not in self . meta . staticfields : self . addField ( f , 'text' ) for d in importdata : name = d [ namefield ] self . add ( name , overwrite = False ) kys = d . keys ( ) for f in fields : if not f in kys : continue try : self . data [ name ] [ f ] = float ( d [ f ] ) except : self . data [ name ] [ f ] = d [ f ] return
Import a list of dicts, each one is a record
Import a list of dicts each one is a record
"""Import a list of dicts, each one is a record"""
self
importdata
namefield
overwrite