def Run(): m = input('Please select a month, format mm: ') y = input('Please select a year, format yyyy: ') comment_option = input('Would you like MedTech Comment emails to be included? Y/N: ') yes_var = ['Yes', 'YES', 'y', 'Y'] no_var = ['No', 'NO', 'n', 'N'] facility_file = open('facilityList.txt', 'r') incident_file = askopenfile(mode='r', initialdir="C:/Documents and Settings/medinc.LGBS/Desktop", title='Please select an incident file!') d = get_facilities(facility_file) incident_list = populate_incident_list(incident_file) mincident_list = list(filter(lambda x: find_date_submitted(x)[0:2] == m, incident_list)) myincident_list = list(filter(lambda x: find_date_submitted(x)[6:10] == y, mincident_list)) if comment_option in yes_var: final_list = [('\t' * 15) + d[find_facility_name(incident)] + '\n' + incident for incident in myincident_list] if comment_option in no_var: final_list = [('\t' * 15) + d[find_facility_name(incident)] + '\n' + incident for incident in myincident_list if boolComments(incident) == False] final_list.sort(key=lambda i: (i[15:18], find_DS_forSort(i))) date_of_incident_before_m = [alert for alert in final_list if find_date_of_incident(alert)[0:2] != m] new_final_list = list(filter(lambda alert: find_date_of_incident(alert)[0:2] == m, final_list)) final_file = asksaveasfile(mode='w', defaultextension=".html", filetypes=(("HTML file", "*.html"),("All Files", "*.*")), initialdir="C:/Documents and Settings/medinc.LGBS/Desktop", title='Please choose a name for the file with this month\'s DOIs!') prior_file = asksaveasfile(mode='w', defaultextension=".html", filetypes=(("HTML file", "*.html"),("All Files", "*.*")), initialdir="C:/Documents and Settings/medinc.LGBS/Desktop", title='Please choose a name for the file with prior month\'s DOIs!') html_styling = ('<html>' + '<head>' + '<style>' + 'hr { page-break-before: always;}' + '''pre { white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;}''' + '</style>' + '</head>' + '<body>') final_file.write(html_styling) for alert in new_final_list: final_file.write('<pre>' + '<font size= "4" face= "Ariel">' + cgi.escape(alert) + '</font>' + '</pre>' + '<hr>') final_file.write('</body>' + '</html>') final_file.close() prior_file.write(html_styling) for alert in date_of_incident_before_m: prior_file.write('<pre>' + '<font size= "4" face= "Ariel">' + cgi.escape(alert) + '</font>' + '</pre>' + '<hr>') prior_file.write('</body>' + '</html>') prior_file.close() print('Sorting complete! Please open html files to see results.')
def text_save(): f = filedialog.asksaveasfile(mode='w', defaultextension=".txt") if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return text2save = """<html><body> """ + body + """ </body></html>""" f.write(text2save) f.close()
def saveAs(): f = filedialog.asksaveasfile(mode='w', defaultextension='.txt') t = text.get(0.0, END) try: f.write(t.rstrip()) except: showError(title="Ooops!", message="Unable to save file.")
def predict_test(self,toFile=False): #Check that the testSet actually exists! if len(self.testSet)>0: #check that the test set contains the same number of levels as the train set if sorted(self.targetLevels) == sorted(np.unique(self.encodedTargetTest)): #testResults contain predictions of the test set predictors testResults=self.predict_class(self.testPredictors) #Accuracy is the number of predictions that match the actual values divided by the number of datapoints in the test set accuracy=sum(list(map(lambda x: x[0]==x[1],zip(testResults,self.encodedTargetTest))))/len(testResults) print('\nTest Accuracy','%s'% float('%.4g'%accuracy)) if toFile: #simple GUI is convenient to use from tkinter.filedialog import asksaveasfile writelocation=asksaveasfile(mode='w+',defaultextension='.txt') writelocation.write('Predicted | Actual \n') #zip predicted an actual into tuples pairedActualPredicted=zip(*[list(testResults),list(self.encodedTargetTest)]) for row in pairedActualPredicted: #write each tuple to the file writelocation.write('\n'+str(row)) if row[0]!=row[1]: #Note any incorrect predictions writelocation.write(' * incorrect prediction') writelocation.close() return accuracy
def save_input(): file2save = filedialog.asksaveasfile(mode = 'w', defaultextension = ".txt") if file2save is None: return inputtext = str(textfield.get("1.0", END)) file2save.write(inputtext) file2save.close()
def save_as(): file = asksaveasfile(defaultextension='.txt') data = text_area.get(0.0, END) try: file.write(data.rstrip()) except: tkinter.messagebox.showinfo("Cancel", "File Not Saved!")
def write_dep(self, Z, fname = None, grid_fname = None): if not fname: fname = filedialog.asksaveasfile() else: fname = fname if not grid_fname: if np.ndim(Z) == 1: m = np.shape(Z)[0] n = 1 else: m = np.shape(Z)[0] n = np.shape(Z)[1] else: grid_fname = grid_fname grid = grd.grd() grid.read_grd(fname = grid_fname) m = grid.m n = grid.n Z = np.array([np.append(i,-999.) for i in Z]) Z = np.insert(Z, -1, np.ones(np.shape(Z[0]))*-999.) Z = Z.reshape((m+1, n+1)) np.savetxt(fname, Z, delimiter = '\t', fmt = '%.3f') print('saved depth file: %s' %os.path.basename(fname)) self.read_dep(fname)
def test(): # MessageBox.showinfo("Hola!","Hola mundo") # MessageBox.showwarning("Alerta","Sección sólo para administradores.") # MessageBox.showerror("Error!","Ha ocurrido un error inesperado.") # resultado = MessageBox.askquestion("Salir","¿Está seguro que desea salir sin guardar?") # if resultado == "yes": # "no" # root.destroy() # resultado = MessageBox.askokcancel("Salir","¿Sobreescribir el fichero actual?") # resultado = MessageBox.askyesno("Salir","¿Está seguro que desea salir sin guardar?") #if resultado: # root.destroy() #resultado = MessageBox.askretrycancel("Reintentar","No se puede conectar") #if resultado: # root.destroy() #color = ColorChooser.askcolor(title="Elige un color") #print(color) #ruta = FileDialog.askopenfilename(title="Abrir un fichero", initialdir="C:", # filetypes=(("Fichero de texto","*.txt"), # ("Fichero de texto avanzado","*.txt2"), # ("Todos los ficheros","*.*")) ) #print(ruta) # equivale a open('ruta','w') fichero = FileDialog.asksaveasfile(title="Guardar un fichero", mode="w", defaultextension=".txt") if fichero is not None: fichero.write("Hola voy a escribir otra cosa!") fichero.close()
def execute_pip_commands(self): """ Execute the command for generating requirements file """ requirements_text = '' for item in self.multi_items_list.scroll_tree.selection(): item_dict = self.multi_items_list.scroll_tree.item(item) requirements_text += '{}=={}\n'.format( item_dict['values'][0], item_dict['values'][1]) from tkinter.filedialog import asksaveasfile from os.path import expanduser file_pt = asksaveasfile( mode='w', defaultextension='.txt', initialdir=expanduser('~')) if file_pt is None: return file_pt.write(requirements_text) file_pt.close()
def saveFile(content) : ''' Use a Tkinter file dialog to allow the user to save content to a file. This is used for the results window in the UI. ''' file = filedialog.asksaveasfile(mode = 'w', defaultextension = '.txt', initialfile = "results") if file != None : print(content, file = file)
def save_sequence(): """ Saves the assembled sequence to a designated location. Args: NONE Returns: NONE Raises: KeyError: Raises an exception. """ global filename global issequencesaved if filename == '': messagebox.showerror("Error Message", "No import file") elif issequencesaved == False: f = filedialog.asksaveasfile(mode='w', defaultextension=".txt") if f is None: return f.write(assembled_reads) f.close() issequencesaved = True else: messagebox.showerror("Error Message", "No assembled sequence")
def __askSaveFilePath(self, extension): file_path = filedialog.asksaveasfile(mode="w", defaultextension=extension) #check if user cancelled saveFileDialog if file_path is None: return #self.image_editor.image.write(file_path, format=extension) self.image_editor.image.save(str(file_path.name))
def saveAs(): f = asksaveasfile(mode='w',defaultextension='.txt') t = text.get(0.0,END) try: f.write(t.rstrip()) except: showerror(title="Error",message="File save fail...")
def save_fichier(self): """ Fonction de sauvegarde dans un fichier(écriture seulement) """ print(self.arbre.toText()) fichier = filedialog.asksaveasfile(parent=self, title="Sauvegarder sous ...") if fichier: fichier.write(self.arbre.toText()) fichier.close()
def save(self): from tkinter import Tk from tkinter.filedialog import asksaveasfile Tk().withdraw() simFile = None try: simFile = asksaveasfile(mode="wb", initialfile='untitled', defaultextension='sim', filetypes=[("Newton's Laboratory Simulation File", ".sim")]) finally: if simFile is None: return data = (self.bodies, self.constraints) for group in data: for obj in group: obj.simulation = None pickle.dump(data, simFile, pickle.HIGHEST_PROTOCOL) simFile.close() for d in data: for x in d: print(x.__dict__) for group in data: for obj in group: obj.simulation = self self.planet = self.bodies[0]
def mergeFiles(): pdfFile = [] reader = [] writer = PyPDF2.PdfFileWriter() mylistboxProgress.delete(0, tk.END) if mylistbox.size() > 1: for i in range(0, len(fileName)): #print(reader[i]) pdfFile.append(open(fileName[i], 'rb')) reader.append(PyPDF2.PdfFileReader(pdfFile[i])) mylistboxProgress.insert(i, extractName(fileName[i]+" - Progress: " + str(((i+1)/len(fileName))*100)+" %")) for pageNum in range(reader[i].numPages): page = reader[i].getPage(pageNum) writer.addPage(page) #pdfFile[i].close() outputName = filedialog.asksaveasfile(title="Save As...", mode='a', defaultextension=".pdf", filetypes =[("Portable Document Format","*.pdf")]) if outputName: outputFile = open(outputName.name, 'wb') writer.write(outputFile) outputFile.close() mylistboxProgress.insert(tk.END, "File saved as: "+outputName.name) else: mylistboxProgress.insert(tk.END, "File not saved") for i in range(0, len(pdfFile)): pdfFile[i].close() return
def kmlWriter(self): self.namePosit = int(self.nameList.curselection()[0]) self.latPosit = int(self.latList.curselection()[0]) self.lonPosit = int(self.lonList.curselection()[0]) self.kmlFile = tfd.asksaveasfile(mode='w', defaultextension='*.kml', filetypes=[('kml File', '*.kml')]) self.kmlFile.write('<?xml version="1.0" encoding="UTF-8"?>\n<kml xmlns="http://www.opengis.net/kml/2.2">\n\t<Document>\n\t') for row in self.sheet.get_squared_range(1,2,self.sheet.max_column,self.sheet.max_row): self.kmlFile.write('<Placemark>\n\t') self.kmlFile.write('<name>' + str(row[self.namePosit].value) + '</name>\n') # Added CDATA tag to solve issue of special characters causing xml to crash. self.kmlFile.write('\t<description> <![CDATA[ \n\t\t\t') # initializes the count method used to loop through description self.c = 1 for colDesc in row: self.kmlFile.write(str(self.sheet.cell(row=1,column=self.c).value) +': ' + str(colDesc.value) + '\n\t\t\t') self.c += 1 self.kmlFile.write(']]> \n\t\t </description>') self.kmlFile.write('<Point>\n\t\t<coordinates>'+str(row[self.lonPosit].value) + ','+ str(row[self.latPosit].value) + ',0</coordinates>\n\t</Point>') self.kmlFile.write('\n\t</Placemark>\n\t') self.kmlFile.write('</Document></kml>') self.kmlFile.close() #Updates the label to indicate conversion is complete. self.complete.set("Conversion Complete!")
def Save_as(self): f = fd.asksaveasfile(mode='w') self.cfile = f.name self.master.wm_title('XRead Text Editor - '+self.cfile) f.write(self.text.get("1.0",END)) f.close() self.file_is_saved=True
def save_command(): file = filedialog.asksaveasfile(mode='w') if file != None: # slice off the last character from get, as an extra return is added data = textPad.get('1.0', END+'-1c') file.write(data) file.close()
def save_file(): file = filedialog.asksaveasfile(mode="w") if file != None: # chop the last character from get, as an added extra return data = self.textPad.get("1.0", END + "-1c") file.write(data) file.close()
def note_save_as(self, event = None): f = filedialog.asksaveasfile(mode='w', defaultextension=".txt") # opens file save dialog if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return text_to_save = str(self.textbox.get(1.0, tk.END)) f.write(text_to_save) f.close()
def savedeckas(self): savefile = filedialog.asksaveasfile(defaultextension='.JSON', mode='w') if savefile is None: # If operation is 'canceled' return savefile.write(json.dumps(usercardlist)) savefile.close()
def process(dataset): datafile = filedialog.asksaveasfile(mode="w", defaultextension=".csv") datacsv = "Value, Name \n" for i, name in enumerate(dataset.getSetNames()): try: datacsv += "{:.1e}".format(dataAndrea(dataset.makePlot(i)))+ ", " + name + "\n" except: datacsv += "ERROR, " + name + "\n" datafile.write(datacsv) datafile.close()
def file_save(): showinfo("INFO","Remember Location Where You Are Saving Your File") if messagebox.askokcancel(title="SAVING LOCATION",message="Enter Location Where You Have To Save The File"): save_file=filedialog.asksaveasfile(mode='w') if save_file!=None: data=texteditor.get('1.0',END+'-1c') save_file.write(data) save_file.close()
def createPageFromTemplate(item, item2): #Gathers input from a template and writes it into a new html file print("creating page") file = filedialog.asksaveasfile(mode='w',defaultextension='.html', initialfile = item2) #creating the new file file.write("<html>") file.write("<body>") file.write(item) file.write("</body>") file.write("</html>")
def file_save(book_id): f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".opml") if f is None: # asksaveasfile return `None` if dialog closed with "cancel". return mind_map_content = get_mind_map_contents(book_id) print(book_id) f.write(mind_map_content) f.close()
def menu_save(self): self.exec_command(key="menu_save") data_list = ss.to_list(self.recv_data) file = tkd.asksaveasfile(mode="w") if not file: return False file.writelines(data_list) file.close()
def getBOMList(self): bFileTxt = filedialog.askopenfile(mode='r', **self.file_opt) if bFileTxt != None: self.parseFileName(str(bFileTxt)) bFileCsv = filedialog.asksaveasfile(mode='w', **self.wfile_opt) if bFileCsv != None: self.parseFileName(str(bFileCsv), fType='csv', mode=1) self.toCSV(bFileTxt, bFileCsv, mode=1)
def Save_as(self): f = fd.asksaveasfile(mode='w') self.wcfile = f.name input_ = self.text.get("1.0",END) output = htmlo(input_) f.write(output) f.close() self.wfile_is_saved=True
def getNetList(self): nFileTxt = filedialog.askopenfile(mode='r', **self.file_opt) if nFileTxt != None: self.parseFileName(str(nFileTxt)) nFileCsv = filedialog.asksaveasfile(mode='w', **self.wfile_opt) if nFileCsv != None: self.parseFileName(str(nFileCsv), fType='csv', mode=1) self.toCSV(nFileTxt, nFileCsv)
def save(): files = [('All Files', '*.*'), ('Python Files', '*.py'), ('Text Document', '*.txt')] file = asksaveasfile(filetypes=files, defaultextension=files)
def save(self): with open("logHistory.txt", "r") as logfile: savefile = filedialog.asksaveasfile(mode='w', defaultextension = ".txt") savefile.write(logfile.read()) savefile.close()
def save(): files = [('Schematic Files', '*.asc'), ('All Files', '*.*')] file = fd.asksaveasfile(filetypes = files, defaultextension = files) return file
def save_file(): save_file = filedialog.asksaveasfile(mode='w', defaultextension=".txt") save_file.write(str(saved_positions)) save_file.close() print("saved file")
def sf(): f3 = filedialog.asksaveasfile(mode='w', title='Save File') if f3 != None: contnew = cont.get('1.0', END + '-1c') f3.write(contnew) f3.close()
def store_to_text(self): txtfile = filedialog.asksaveasfile(mode='w', defaultextension=".txt") self.path = txtfile #txtfile = open('data.txt','w') txtfile.write(self.str) txtfile.close()
def nmea2csv(entree='optionnel', fichier='optionnel'): """ Enregistre sous le nom ``fichier`` le contenu reformaté des trames nmea contenues dans le fichier ``entree``. Si entree et/ou fichier n'est pas précisé, ouvre une boite de dialogue pour le sélectionner. Arguments: entree (file, otionnel): Le nom complet (avec le chemin) d'un fichier contenant des trames nmea au format texte brut. fichier (file, optionnel): Le nom complet (avec le chemin) d'un fichier au format csv. """ if entree == 'optionnel': fen = Tk.Tk() fich = tkf.askopenfilename( initialdir=".", title="Choisissez un fichier contenant des trames nmea.", filetypes=(("text", "*.txt"), ("all files", "*.*"))) try: fen.destroy() except BaseException: pass if not not fich: #si fich contient quelque chose de différent de None ou () entree = fich else: return False if fichier == 'optionnel': fen = Tk.Tk() fich = tkf.asksaveasfile( parent=fen, mode='w', title="Choisissez un fichier pour l'enregistrement au format csv") try: fen.destroy() except BaseException: pass if not not fich: #si fich contient quelque chose fichier = fich.name print(fich.name) else: return False if entree != 'optionnel': ch = fich2chaine(entree) if fichier != 'optionnel': filout = open(fichier, 'w') intitules = "'type', 'date', 'heure', 'chrono (s)', 'latitude (° décimaux)', 'longitude (° décimaux)', 'altitude (m)', 'vitesse (km/h)', 'num_sats', 'horizontal dilution of precision (m)', 'cap vrai (°)'" intitules = intitules.replace('\'', '\"') filout.write(intitules) excep = 0 origin = None for line in ch.split("\n"): try: msg = pynmeagps.NMEAReader.parse(line) if msg.msgID == 'RMC' and origin == None: origin = datetime.datetime.combine( msg.date, msg.time ) #origin est le premier horaire, à la date du relevé nmea msg2 = mk_list(msg, origin) msg2 = str(msg2).replace('[', '') msg2 = msg2.replace(']', '\n') msg2 = msg2.replace('.', ',') msg2 = msg2.replace('\'', '\"') filout.write(msg2) except Exception as e: excep = 1 if excep == 1: print('Error while parsing in nmea2csv().') filout.close() return True else: return False else: return False
def save(self): f = filedialog.asksaveasfile(mode='w', **self.file_opt) if f: self.writeCoeff(f) else: print(f)
def save_file_text(self): f = asksaveasfile(mode='w', defaultextension=".png") if f: self.ip.change_image_character(self.ip.get_only_B(self.image), f.name, savedata=True)
def other_save_file(self): f = filedialog.asksaveasfile(filetypes=[('TXT', '.txt')]) if f: f.write(self.get_text()) tkinter.messagebox.showinfo('提示', '保存成功')
def save_as_file(self): f = filedialog.asksaveasfile(mode='w', defaultextension=".mb") return f
def save(self): """ Save a file """ logger.debug("Popping Save browser") return filedialog.asksaveasfile(**self.kwargs)
def Save(self): files = [('Text Document', '*.txt'),('Python File', '*.py'), ("Excel File",'*.XLS'), ("Word Document File",'.doc')] file = filedialog.asksaveasfile(mode="w",filetypes = files, defaultextension = files) file.write("******************************Memorandom of Marks******************************") text0 = self.lineEdit_Student_name.text(), text1 = self.lineEdit_Father_name.text(), text2 = self.comboBox_Class.currentText(), text3 = self.lineEdit_Hall_Ticket_Number.text(), text4 = self.dateEdit.text(), text5 = self.textEdit_Telugu.toPlainText(), text6 = self.textEdit_Hindi.toPlainText(), text7 = self.textEdit_English.toPlainText(), text8 = self.textEdit_Maths.toPlainText(), text9 = self.textEdit_Science.toPlainText(), text10 = self.textEdit_Social.toPlainText(), text11 = self.textEdit_Total.toPlainText(), text12 = self.textEdit_Average.toPlainText(), text13 = self.textEdit_Percentage.toPlainText(), text14 = self.textEdit__Division.toPlainText(), text15 = self.textEdit_Result.toPlainText(), file.write("\nStudent Name : ") file.writelines(text0) file.write("\nFather's Name : ") file.writelines(text1) file.write("\nClass : ") file.writelines(text2) file.write("\nHall Ticket Number : ") file.writelines(text3) file.write("\nDate of Birth : ") file.writelines(text4) file.write("\nTotal Telugu Marks Obtained Out of 100.00 : ") file.writelines(text5) file.write("/100.00") file.write("\nTotal Hindi Marks Obtained Out of 100.00 : ") file.writelines(text6) file.write("/100.00") file.write("\nTotal English Marks Obtained Out of 100.00 : ") file.writelines(text7) file.write("/100.00") file.write("\nTotal Mathematics Marks Obtained Out of 100.00 : ") file.writelines(text8) file.write("/100.00") file.write("\nTotal Science Marks Obtained Out of 100.00 : ") file.writelines(text9) file.write("/100.00") file.write("\nTotal Social Marks Obtained Out of 100.00 : ") file.writelines(text10) file.write("/100.00") file.write("\nTotal Marks Obtained by the Student Out of 600.00 : ") file.writelines(text11) file.write("/600.00") file.write("\nAverage of the Total Marks Obtained Out of 100.00 : ") file.writelines(text12) file.write("/100.00") file.write("\nPercentage of the Total Marks Obtained Out of 100.00% : ") file.writelines(text13) file.write("/100.00%") file.write("\nDivision : ") file.writelines(text14) file.write("\nResult : ") file.writelines(text15) file.write("\n*******************************************************************************") file.close() sys.exit()
from xlwt import Workbook from tkinter.filedialog import asksaveasfile Wb__obj = Workbook() my_sheet = Wb__obj.add_sheet('python_class') my_sheet.write(0, 0, 'sparsh') my_sheet.write(0, 1, 'prabal') my_sheet.write(0, 2, 'dhruv') f = asksaveasfile(mode='w', defaultextension='.csv') if f is not None: Wb__obj.save(f.name) f.close()
def saveAs(self): files = [('All Files', '*.*'), ('Text Documents', '*.txt')] file = filedialog.asksaveasfile(filetypes=files, defaultextension=files)
def save_dialog(self): self.url = filedialog.asksaveasfile(mode="w", filetypes=[("All Files", "*.*"), ("Text documents", "*.txt*")], defaultextension=".ntxt")
def save(self): f = filedialog.asksaveasfile('w', filetypes=(("JSON file", "*.json"), ("All files", "*.*"))) f.write(self.automaton.getJSON()) f.close()
def saveFile(): root = tk.Tk() root.withdraw() file_path = filedialog.asksaveasfile(mode='w') return file_path
def saveFile(self): if self.currentSignal: filename = filedialog.asksaveasfile(mode='w', defaultextension=".xls") if filename: SignalsReadWrite.writeSignal(self.currentSignal, filename.name)
def save(): file = filedialog.asksaveasfile(parent=window, mode='w') if file != None: lines = text.get('1.0', END+'-1c') file.write(lines) file.close()
def savedocx(self): files = [('docx', '*.docx*')] out = filedialog.asksaveasfile(filetypes = files, defaultextension = '.docx') self.outp = out.name lbl = Label(text=self.outp) lbl.pack()
def saveFile(): file = filedialog.asksaveasfile(mode='w') if file != None: data = textarea.get('1.0', END + '-1c') file.write(data) file.close()
def save_links(self, tkList: tk.Listbox): with filedialog.asksaveasfile(mode='w', defaultextension=("text files", "*.txt")) as file: data = tkList.get(0, "end") file.write("\n".join(data))
def save_dialog(self): f = filedialog.asksaveasfile(mode='w+', defaultextension=".csv") if f is None: return self.saveAsCsv(f) f.close()
foldername = filedialog.askdirectory() rows_list = [] try: for each in tqdm(os.listdir(foldername)): if each.endswith('.pdf') or each.endswith('.docx'): data = resumeExtractor( foldername + '/' + each, skills_file='resumext/skills.csv').get_extracted_data() rows_list.append(data) if each.endswith('.doc'): try: import textract except: continue data = resumeExtractor(foldername + '/' + each).get_extracted_data() rows_list.append(data) except: print('\nError : Folder not chosen\n') continue df = pd.DataFrame(rows_list) print('Where do you want to save the file?\n') files = [('All Files', '*.*'), ('Excel Files', '.xlsx')] try: file = asksaveasfile(filetypes=files, defaultextension=".xlsx") df.to_excel(file.name) except: print('Error : File location or name not choosen correctly\n') continue print('File saved!\n')
except ValueError: # Retorna uma lista com uma mensagem de erro, pois alguma coisa deu errado # no processo return [ "Erro na geração da lista do SPED final C170!", "Conferir o 'modulo ler_e_extrair'." ] arq_sped = filedialog.askopenfilename(filetypes=(("txt files", "*.txt"), ("all files", "*.*"))) if arq_sped != "()": arq = open(arq_sped, 'rb') lista_das_linhas_sped = arq.readlines() final_sped = ler_e_extrair(lista_das_linhas_sped) arq.close() novo = filedialog.asksaveasfile(mode="wb", defaultextension=".txt", filetypes=(("txt files", "*.txt"), ("all files", "*.*"))) if novo != "()": novo.writelines(final_sped) novo.close()
def save_chat(self): filename = filedialog.asksaveasfile() if filename: with open(filename, "w") as f: f.write(self.text_area.get(0.0, END))
def save_as(event): global FILE_NAME tracking('save_as') out = asksaveasfile(mode='w', defaultextension='.txt') data = text.get('1.0', tkinter.END)
def save_file(self): f = asksaveasfile(mode='w', defaultextension=".png") if f: self.ip.save(f.name, self.image)
except ValueError: continue try: dateTime = datetime.strptime(value[3], "%Y-%m-%dT%H:%M:%S").timestamp() except ValueError: dateTime = 0 val_points.append((dateTime, T)) fileRad.close() val_points = dict((x,y) for x, y in val_points) vals = [] for key in val_points.keys(): vals.append((key, val_points[key])) def getKey(item): return item[0] val_points = sorted(vals, key=getKey) fileRes = filedialog.asksaveasfile('w') fileRes.write('PAGE PAGESTARTDATETIME VALUE GPSTIME LAT LON ALT SAT PAGEENDDATETIME' + '\n') for point in val_points: LatLonAlt = LatLonAltInterpolFunc.getLatLonAlt(point[0]) resPoint = point + LatLonAlt fileRes.write('0' + '\t' + str(datetime.fromtimestamp(resPoint[0]).strftime('%y.%m.%dT%H:%M:%S')) + '\t' + str(resPoint[1]) + '\t' + str(datetime.fromtimestamp(resPoint[0]).strftime('%y.%m.%dT%H:%M:%S')) + '\t' + str(resPoint[3]) + '\t' + str(resPoint[2]) + '\t' + str(resPoint[4]) + '\t' + '0' + '\t' '0' + '\n') fileRes.close()