def rewritefile(layer): with file(filename, 'w') as f: f.write( "name,size,id\ntoad,small,5\nmole,medium,6\nbadger,big,7\n" ) # print "Rewritten file - sleeping" time.sleep(1) QCoreApplication.instance().processEvents()
def deletefile(layer): try: os.remove(filename) except: file(filename, "w").close() assert os.path.getsize(filename) == 0, "removal and truncation of {} failed".format(filename) # print "Deleted file - sleeping" time.sleep(1) QCoreApplication.instance().processEvents()
def deletefile(layer): try: os.remove(filename) except: file(filename, "w").close() assert os.path.getsize( filename ) == 0, "removal and truncation of {} failed".format(filename) # print "Deleted file - sleeping" time.sleep(1) QCoreApplication.instance().processEvents()
def appendfile(layer): with file(filename, 'a') as f: f.write('3,tigger\n') # print "Appended to file - sleeping" time.sleep(1) QCoreApplication.instance().processEvents()
#setup array item_list = [] items = self.data_table.selectedItems() for item in items: try: item_list.append(float(item.text())) except: pass data_array = np.asarray(item_list) mean_value = np.mean(data_array) print("Mean = {0:5f}".format(mean_value)) self.mean_label.setText("Mean = {:0.3f}".format(mean_value)) ''' Assignment: 1. Add all the quantities from the MS Excel descriptive Statistics add-in to automatically calculate and display. Demonstrate the results from this program match Excel. Use the same dataset. 2. Add a dialog box to open and load any Comma Separated Values table. ''' if __name__ == '__main__': #Start the program this way according to https://stackoverflow.com/questions/40094086/python-kernel-dies-for-second-run-of-pyqt5-gui app = QCoreApplication.instance() if app is None: app = QApplication(sys.argv) execute = StatCalculator() sys.exit(app.exec_())
def rewritefile(layer): with file(filename, 'w') as f: f.write("name,size,id\ntoad,small,5\nmole,medium,6\nbadger,big,7\n") # print "Rewritten file - sleeping" time.sleep(1) QCoreApplication.instance().processEvents()