PEATDB/Tables_IO.py
def ImportTableModel(self,filename):
        """Import table data from a comma separated file and create data for a model
           This is reusable outside the GUI dialog also."""
            
        import os
        if not os.path.isfile(filename):
            return None
        try:
            sep = self.var_sep.get()
        except:
            sep = ','
            
        #takes first row as field names
        dictreader = csv.DictReader(open(filename, "rb"), delimiter=sep)
        dictdata = {}
        count=0
        for rec in dictreader:            
            dictdata[count]=rec
            count=count+1
        print dictdata 
        
        modeldata={} 
        modeldata['columnnames']=[]
        modeldata['columntypes']={}
        modeldata['columnlabels']={}
        count=0
        modeldata['columnnames'] = dictdata[0].keys()
        
        #check for col types, text or num?
        for col in modeldata['columnnames']:
            '''coltype='text'
            for row in dictdata.keys():
                if 
            modeldata['columntypes'][col]=coltype'''
            modeldata['columntypes'][col] = 'text'
            
        for colname in modeldata['columnnames']:
            modeldata['columnlabels'][colname]=colname          
        
        #now add the data
        for row in dictdata.keys():
            modeldata[row]=dictdata[row]                
            
        print '-------MODELDATA------\n',modeldata          

        return modeldata
Import table data from a comma separated file and create data for a model
           This is reusable outside the GUI dialog also.
Import table data from a comma separated file and create data for a model
This is reusable outside the GUI dialog also.
Import table data from a comma separated file and create data for a model This is reusable outside the GUI dialog also .
def ImportTableModel(self,filename):
        import os
        if not os.path.isfile(filename):
            return None
        try:
            sep = self.var_sep.get()
        except:
            sep = ','
        dictreader = csv.DictReader(open(filename, "rb"), delimiter=sep)
        dictdata = {}
        count=0
        for rec in dictreader:            
            dictdata[count]=rec
            count=count+1
        print dictdata 
        modeldata={} 
        modeldata['columnnames']=[]
        modeldata['columntypes']={}
        modeldata['columnlabels']={}
        count=0
        modeldata['columnnames'] = dictdata[0].keys()
        for col in modeldata['columnnames']:
            modeldata['columntypes'][col] = 'text'
        for colname in modeldata['columnnames']:
            modeldata['columnlabels'][colname]=colname          
        for row in dictdata.keys():
            modeldata[row]=dictdata[row]                
        print '-------MODELDATA------\n',modeldata          
        return modeldata
def ImportTableModel ( self , filename ) : import os if not os . path . isfile ( filename ) : return None try : sep = self . var_sep . get ( ) except : sep = ',' dictreader = csv . DictReader ( open ( filename , "rb" ) , delimiter = sep ) dictdata = { } count = 0 for rec in dictreader : dictdata [ count ] = rec count = count + 1 print dictdata modeldata = { } modeldata [ 'columnnames' ] = [ ] modeldata [ 'columntypes' ] = { } modeldata [ 'columnlabels' ] = { } count = 0 modeldata [ 'columnnames' ] = dictdata [ 0 ] . keys ( ) for col in modeldata [ 'columnnames' ] : '''coltype='text'
            for row in dictdata.keys():
                if 
            modeldata['columntypes'][col]=coltype''' modeldata [ 'columntypes' ] [ col ] = 'text' for colname in modeldata [ 'columnnames' ] : modeldata [ 'columnlabels' ] [ colname ] = colname for row in dictdata . keys ( ) : modeldata [ row ] = dictdata [ row ] print '-------MODELDATA------\n' , modeldata return modeldata
Import table data from a comma separated file and create data for a model
This is reusable outside the GUI dialog also.
Import table data from a comma separated file and create data for a model This is reusable outside the GUI dialog also .
"""Import table data from a comma separated file and create data for a model
           This is reusable outside the GUI dialog also.""" #takes first row as field names #check for col types, text or num? '''coltype='text'
            for row in dictdata.keys():
                if 
            modeldata['columntypes'][col]=coltype''' #now add the data
self
filename