Beispiel #1
0
def KeyFromHeaders(databasepath,TableName='Headers',keyName='key'):      
     SQL_query='Select distinct ' + keyName+ ' from '+TableName +' order by '+keyName +' ;'
     
     #databasepath is a file name
     if isinstance(databasepath,str):
         SourceData=OpenDB(databasepath)
         SourceData.execute(SQL_query)
     #databasepath is NewMDB
     else:
         dbp=databasepath.OUTmdbName
         SourceData=OpenDB(dbp)
         SourceData.execute(SQL_query)
     
     result= SourceData.GetVariable(keyName)
     print('copyheaders 242', result)
     return(result)
    def __init__(self,
                 prompt="Select !!input!! database file",
                 DefaultDirec="T:\\",
                 FileExt="Access Files (*.mdb *.accdb)"):

        app = QApplication(sys.argv)
        self.w = QWidget()
        self.MDBfile = getOpenFileNames(self.w, prompt, DefaultDirec,
                                        FileExt)[0][0]
        self.ODB = OpenDB(self.MDBfile)
        del self.w, app
    def __init__(self,
                 prompt="Select !!input!! database file",
                 DefaultDirec="T:\\",
                 FileExt="Access Files (*.mdb *.accdb)"):

        app = QtGui.QApplication(sys.argv)
        self.w = QtGui.QWidget()
        self.MDBfile = QtGui.QFileDialog.getOpenFileNamesAndFilter(
            self.w, prompt, DefaultDirec, FileExt)[0][0]
        #print ('\nInputOutputMDB 17,MDBfile',MDBfile)
        #MDBfile='D:\\scratch\\GreenUrchin_NoLink00.mdb'
        self.ODB = OpenDB(self.MDBfile)
        del self.w, app
    def Randval(self,n=None,EquiProb=True):
      '''ADOWeightVal.Randval(self,n=None,EquiProb=True)
      if n=None, returns a single random value
      if EquiProb, returned values are equiprobable- but in a random order'''
      if n==None:return(self.RandSource.rvs())
		
      if not(EquiProb):
        try:
          return(self.RandSource.rvs(n))
        except:
          return(self.RandSource.rvs(n))

      # EquiProb is true
      p=array(list(map(lambda i:(i+.5)/n,range(n) )))
      EPV=self.RandSource.isf(p)
      shuffle(EPV)
      return(EPV)


if __name__ == "__main__":
    databasepath='H:\AnalysisPrograms2013\PyFunctions\Geoduck\SampleAIP\Geoduck_Bio2.mdb'
    ODB=OpenDB(databasepath)
    SurveyTitle='Malcolm Island, 2013'
    Year=2013
    SurveySite=2
    test=ADOWeightVal(ODB,SurveyTitle,Year,SurveySite=SurveySite)
    print('test.EstMeanWeight',test.EstMeanWeight)
    print('test.MeanWeightSE',test.MeanWeightSE)
    print('test.RandVal()',test.Randval())
    print('test.RandVal(n=5)',test.Randval(n=5))
Beispiel #5
0
    #Disection, SF and Density data are written transect-by-transect
    for k in keys:
        oDensity.CopyRecordToNew(newmdb,key=k)    
        oDissection.CopyRecordToNew(newmdb,key=k)    
        oSF.CopyRecordToNew(newmdb,key=k)  
    
    #Add a record of NULLs because sometimes the last record disappears from the table.
    oDensity.AppendNullRecord(newmdb)
    oDissection.AppendNullRecord(newmdb)
    oSF.AppendNullRecord(newmdb)

if __name__ == "__main__":
    
    
    databasepath='d:\\scratch\\CopyGreenUrchin_Bio.mdb'
    databasepath='d:\\scratch\\ORI.mdb'
    SourceMDB=OpenDB(databasepath)   
    
    OUTmdbName='d:\\scratch\\ORI.mdb'
    OUTmdbName='d:\\scratch\\test.mdb'
    if os.path.exists (OUTmdbName):os.remove (OUTmdbName)
    newmdb=NewMDB(OUTmdbName)
    
    #Indicate specific surveys through a list of dictionaries
    SurveyYear=[\
        {'SurveyTitle':'Nov04Stephenson','Year':2004},\
        {'SurveyTitle':'Oct12Stephenson','Year':2012},\
        {'SurveyTitle':'Mar14FulfordReef','Year':2014}]
        
    CopyMDB(SourceMDB,newmdb,SurveyYear)
    del newmdb