Esempio n. 1
0
    def parseButton_clicked(self):
        csv2excelwbPath = self.lookForCsv2Excel()
        rwparser = RwParser()
        savePath = self.dirName + "/" + self.fileNameNoExt
        if self.excelCheckBox.isChecked():
            # filter, calculate hourly, running streaks etc.
            
            rwparser.parseDistData(self.distCsvName, self.fileNameNoExt, 
                self.newFolderPath, self.qtStartDateTime, self.qtEndDateTime)
            self.changableLabel.setText("Parsing complete.")

            self.disableButtons()
            
            self.changableLabel.setText("Compiling excel worksheet. Please wait...")

            # Pop-up info box for user feedback
            msgBox = QtGui.QMessageBox()
            QtGui.QPlainTextEdit.LineWrapMode
            msgBox.setText("Compiling Excel workbook with csv output. Please wait. (Don't panic, the program may not respond for a few minutes.)")
            msgBox.exec_()

            # call csv2execlwb.py/.exe
            self.callCsv2Excel()

            # More feedback
            msgBox = QtGui.QMessageBox()
            msgBox.setText("Excel file complete! Results can be found in the " + savePath + " directory.")
            msgBox.exec_()
            
            # Export to Excel
            # This block is not currently used. Reserved for future. Hopefully,
            # I can figure out the segfault error and integrate the export
            # to excel portion back into the script.
            # rwparser.exportToExcel(self.fileNameNoExt, self.newFolderPath)
            
            self.changableLabel.setText("Finished compiling Excel workbook.")
            # Turn controls back on when done
            self.enableButtons()
        else: # pass onto
            rwparser.parseDistData(self.distCsvName, self.fileNameNoExt, 
                self.newFolderPath, self.qtStartDateTime, self.qtEndDateTime)
            self.changableLabel.setText("Parsing complete.")
            self.disableButtons()
            
            # Pop-up info box for user feedback
            msgBox = QtGui.QMessageBox()
            QtGui.QPlainTextEdit.LineWrapMode
            msgBox.setText("Parsing complete. Results can be found in the " + savePath + " directory ")
            msgBox.exec_()
            self.enableButtons()
Esempio n. 2
0
    def openButton_clicked(self):
        self.fileNameTuple = QtGui.QFileDialog.getOpenFileName(self,
            "Open VitalView data file (.asc)", "", "ASCII Files (*.asc);;All Files (*.*)")
        
        if self.fileNameTuple[0] != '':
            rwparser = RwParser() # create rwparser class object
            
            # Get filename and Path information
            self.fullFilePath, self.dirName, self.fullFileName, \
                self.fileNameNoExt = rwparser.getFileNamesAndDir(self.fileNameTuple)
            
            # Check the header, if its correct...
            isCorrectHeader = rwparser.checkFileHeader(self.fullFilePath, MAIN_HEADER)
            if isCorrectHeader:
                # Create a new folder to house the parsed data and get path
                self.newFolderPath = rwparser.mkParsedFolder(self.dirName, self.fileNameNoExt)
                
                # Begin first pass - gets all time variables, parses first 3 files
                self.uniqueDates, self.startTime, self.endTime, self.distCsvName = \
                    rwparser.firstPass(self.fullFilePath, self.fileNameNoExt, self.newFolderPath)
                
                # Fill out the combo boxes
                self.startDateCombo.addItems(self.uniqueDates)
                self.endDateCombo.addItems(self.uniqueDates)
                
                # set the start and endDate combos to the first and last unique date
                self.startDateCombo.setCurrentIndex(1)
                self.endDateCombo.setCurrentIndex(len(self.uniqueDates)- 1)
                
                # Turn time strings into QTime obj and fill out time edits
                self.qtEndTime = QtCore.QTime.fromString(self.endTime, 'hh:mm:ss')
                self.qtStartTime = QtCore.QTime.fromString(self.startTime, 'hh:mm:ss')
                self.startTimeEdit.setTime(self.qtStartTime)
                self.endTimeEdit.setTime(self.qtEndTime)              
                               
                # Update all current QDateTime objects
                self.updateQtDateTimes()
                self.limitTimeEdit()
                  
                # Allow user to access filters and buttons
                self.enableButtons()

                # Change label to give user feedback
                self.changableLabel.setText(self.fullFileName + ' successfully loaded.')
            
            else:
                self.changableLabel.setText(self.fullFileName + ' is not a VitalView file')