コード例 #1
0
 def parse(self):
     
     __sheetnames = [u'Q1 GeneralData', 
           u'Q2 EnergyConsumption', 
           u'Q3_ Processes', 
           u'Q3A', 
           u'Q4H_HeatGeneration', 
           u'Q4C_ColdGeneration', 
           u'Q5_Distribution', 
           u'Q6_HeatRecovery', 
           u'Q7_ Renewables', 
           u'Q8 Buildings', 
           u'Q9 Economics']
     
     dlg = DialogGauge(None,"OpenOffice Calc Parsing","reading document")
     self.__md = self.__connectToDB()
     xmlString = self.readOOContent(self.__filepath)
     dlg.update(10)
     parsedDom = xml.dom.minidom.parseString(xmlString)
     dlg.update(53)
     
     __handle, lists = self.__getLists(parsedDom, dlg, __sheetnames)
     DButil = Utils(self.__md, __sheetnames)
     __handle = DButil.writeToDB(lists)
     dlg.update(100)
     dlg.Destroy()
     return __handle
コード例 #2
0
 def parseold(self):
     dlg = DialogGauge(None,"OpenOffice Calc Parsing","reading document")
     self.__md = self.__connectToDB()
     xmlString = self.readOOContent(self.__filepath)
     dlg.update(10)
     self.__parsedDom = xml.dom.minidom.parseString(xmlString)
     dlg.update(53)
     __handle, lists = self.__getLists(dlg, self.sheetnames)
     if len(lists)==0:
         return __handle
     DButil = Utils(self.__md, self.sheetnames)
     __handle = DButil.writeToDB(lists)
     dlg.update(100)
     dlg.Destroy()
     return __handle
コード例 #3
0
 def parse(self):
     dlg = DialogGauge(None,"Excel Parsing","reading document")
     Q1 = Q2 = QProduct = QFuel = Q3 = QRenewables = QSurf = QProfiles = QIntervals = Q9Questionnaire = []
     try:
         self.__xlApp, self.__xlWb = self.__openExcelDispatch(self.__filepath)
         __sheets = self.__xlWb.Sheets
         self.__sheetnames = []
         for i in xrange(0,__sheets.count):
             if __sheets[i].Name[0] == 'Q':
                 self.__sheetnames.append(__sheets[i].Name)
         self.__md = self.__connectToDB()
         
     except:
         self.__closeExcelDispatch(self.__xlWb, self.__xlApp)
         return Utils.parseError("Consistency")
     dlg.update(5)
     try:
         __handle, lists = self.__getExcelLists(self.__sheetnames, self.__xlWb,dlg)
     except:
         try:
             time.sleep(3)
             self.__xlApp, self.__xlWb = openExcelDispatch()
             __handle, lists = self.__getExcelLists(self.__sheetnames, self.__xlWb,dlg)
         except:
             try:
                 time.sleep(3)
                 self.__xlApp, self.__xlWb = openExcelDispatch()
                 __handle, lists = self.__getExcelLists(self.__sheetnames, self.__xlWb, dlg)
             except:
                 self.__closeExcelDispatch(self.__xlWb, self.__xlApp)
                 return Utils.parseError("Consistency")
             
     
     DButil = Utils(self.__md, self.__sheetnames)
     dlg.update(75)
     __handle = DButil.writeToDB(lists)
     dlg.update(100)
     dlg.Destroy()
     self.__closeExcelDispatch(self.__xlWb, self.__xlApp)
     return __handle