obs4MIPs/Toolbox/ESGFexcel.py
def ReadXCL(self):
        '''
        Read Excel Table and fill rc variable related field.
        '''
        try:
           import xlrd
        except:
           print("****** Could not find xlrd Python Package ****")
           print("****** Please install xlrd package to read excel files ****")

        if( os.path.isfile(self.xcl) ):
                wb=xlrd.open_workbook(self.xcl)
        else:
           print("****** Could not find {} file ****".format(self.xcl))
           print("****** Please check excel file name ****")
           raise NameError(self.xcl)

        sheet=wb.sheet_by_name('Variables')

        self.resources['cmor_var']    = [ sheet.row( i )[ 0 ].value.\
                                          encode('ascii','ignore') \
                                          for i in arange(sheet.nrows-2) + 2 ]

        self.resources['original_var'] = [ sheet.row( i )[ 1 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2 ]

        self.resources['original_units']=[ sheet.row( i )[ 2 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2 ]

        self.resources['level']         =[ sheet.row( i )[ 3 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2]

        self.resources['equation']     =[ sheet.row( i )[ 6 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2 ]

        # -----------------------------------------------------------------
        # Make sure it is a string. The main program will call eval on it.
        # -----------------------------------------------------------------
        self.resources['cmor_var']       = str(self.resources['cmor_var'] )
        self.resources['original_var']   = str(self.resources['original_var'])
        self.resources['original_units'] =str(self.resources['original_units'])
        self.resources['equation']       =str(self.resources['equation'])
        self.resources['level']          =str(self.resources['level'])
        return 1

        Read Excel Table and fill rc variable related field.
        
Read Excel Table and fill rc variable related field.
Read Excel Table and fill rc variable related field .
def ReadXCL(self):
        try:
           import xlrd
        except:
           print("****** Could not find xlrd Python Package ****")
           print("****** Please install xlrd package to read excel files ****")
        if( os.path.isfile(self.xcl) ):
                wb=xlrd.open_workbook(self.xcl)
        else:
           print("****** Could not find {} file ****".format(self.xcl))
           print("****** Please check excel file name ****")
           raise NameError(self.xcl)
        sheet=wb.sheet_by_name('Variables')
        self.resources['cmor_var']    = [ sheet.row( i )[ 0 ].value.\
                                          encode('ascii','ignore') \
                                          for i in arange(sheet.nrows-2) + 2 ]
        self.resources['original_var'] = [ sheet.row( i )[ 1 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2 ]
        self.resources['original_units']=[ sheet.row( i )[ 2 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2 ]
        self.resources['level']         =[ sheet.row( i )[ 3 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2]
        self.resources['equation']     =[ sheet.row( i )[ 6 ].value.\
                                           encode('ascii','ignore') \
                                           for i in arange(sheet.nrows-2) + 2 ]
        self.resources['cmor_var']       = str(self.resources['cmor_var'] )
        self.resources['original_var']   = str(self.resources['original_var'])
        self.resources['original_units'] =str(self.resources['original_units'])
        self.resources['equation']       =str(self.resources['equation'])
        self.resources['level']          =str(self.resources['level'])
        return 1
def ReadXCL ( self ) : try : import xlrd except : print ( "****** Could not find xlrd Python Package ****" ) print ( "****** Please install xlrd package to read excel files ****" ) if ( os . path . isfile ( self . xcl ) ) : wb = xlrd . open_workbook ( self . xcl ) else : print ( "****** Could not find {} file ****" . format ( self . xcl ) ) print ( "****** Please check excel file name ****" ) raise NameError ( self . xcl ) sheet = wb . sheet_by_name ( 'Variables' ) self . resources [ 'cmor_var' ] = [ sheet . row ( i ) [ 0 ] . value . encode ( 'ascii' , 'ignore' ) for i in arange ( sheet . nrows - 2 ) + 2 ] self . resources [ 'original_var' ] = [ sheet . row ( i ) [ 1 ] . value . encode ( 'ascii' , 'ignore' ) for i in arange ( sheet . nrows - 2 ) + 2 ] self . resources [ 'original_units' ] = [ sheet . row ( i ) [ 2 ] . value . encode ( 'ascii' , 'ignore' ) for i in arange ( sheet . nrows - 2 ) + 2 ] self . resources [ 'level' ] = [ sheet . row ( i ) [ 3 ] . value . encode ( 'ascii' , 'ignore' ) for i in arange ( sheet . nrows - 2 ) + 2 ] self . resources [ 'equation' ] = [ sheet . row ( i ) [ 6 ] . value . encode ( 'ascii' , 'ignore' ) for i in arange ( sheet . nrows - 2 ) + 2 ] self . resources [ 'cmor_var' ] = str ( self . resources [ 'cmor_var' ] ) self . resources [ 'original_var' ] = str ( self . resources [ 'original_var' ] ) self . resources [ 'original_units' ] = str ( self . resources [ 'original_units' ] ) self . resources [ 'equation' ] = str ( self . resources [ 'equation' ] ) self . resources [ 'level' ] = str ( self . resources [ 'level' ] ) return 1
Read Excel Table and fill rc variable related field.
Read Excel Table and fill rc variable related field .
'''
        Read Excel Table and fill rc variable related field.
        ''' # ----------------------------------------------------------------- # Make sure it is a string. The main program will call eval on it. # -----------------------------------------------------------------
self