def start_window():
	import import_from_xlsx

	if not hasattr(import_from_xlsx, 'load_state'):
		setattr(import_from_xlsx, 'load_state', True)
	else:
		reload(import_from_xlsx)
	
	''' tag library '''
	'''
	each tag library corresponds to sqlite table name
	each tag corresponds to sqlite database column name
	'''

	''' config file '''
	config = configparser.ConfigParser()
	config.read(controllers + 'config.ini', encoding='utf-8')

	def convert_to_db():
		source = import_from_xlsx.import_xlsx_path.get_()
		destination = import_from_xlsx.destination_path.get_()

		convert_xlsx_to_db.convert_database(source, destination)
		import_from_xlsx.import_from_xlsx.destroy()

	import_from_xlsx.import_browse_button.settings(\
		command=lambda: import_from_xlsx.import_xlsx_path.set(filedialog.askopenfile().name))
	import_from_xlsx.time_browse_button.settings(\
		command=lambda: import_from_xlsx.time_xlsx_path.set(filedialog.askopenfile().name))
	import_from_xlsx.destination_browse_button.settings(\
		command=lambda: import_from_xlsx.destination_path.set(filedialog.asksaveasfilename() + '.db'))
	import_from_xlsx.cancel_button.settings(command=import_from_xlsx.import_from_xlsx.destroy)
	import_from_xlsx.import_button.settings(command=convert_to_db)
Example #2
0
 def findEEPath(self):
   if sys.platform[:3] == 'win': #for windows, wince, win32, etc
     file=filedialog.askopenfile(filetypes=[("Programs","*.exe"),("All files","*")],title="Choose External Editor",parent=self)
   else:
     file=filedialog.askopenfile(filetypes=[("All files","*")],title="Choose External Editor",parent=self)
   if file != None:
     name = os.path.abspath(file.name)
     file.close()
     self.ee.delete(0,END)
     self.ee.insert(END,name)
     self.validate()
Example #3
0
 def findAsyPath(self):
   if sys.platform[:3] == 'win': #for windows, wince, win32, etc
     file=filedialog.askopenfile(filetypes=[("Programs","*.exe"),("All files","*")],title="Find Asymptote Executable",parent=self)
   else:
     file=filedialog.askopenfile(filetypes=[("All files","*")],title="Find Asymptote Executable",parent=self)
   if file != None:
     name = os.path.abspath(file.name)
     file.close()
     self.ap.delete(0,END)
     self.ap.insert(END,name)
     self.validate()
Example #4
0
 def show_test_vad_open(self, path=path_to_test):
     askopenfile = filedialog.askopenfile(filetypes=[("Wave audio files", "*.wav *.wave")], defaultextension=".wav",
                                          initialdir=path)
     if not askopenfile is None:
         test(WavFile(askopenfile.name), self.nbc)
     else:
         messagebox.showwarning("Warning", "You should select one file. Please, try again")
Example #5
0
def run():
	Tk().withdraw() #dont need a console open
	if sys.version_info[0] < 3:
		zippath = tkFileDialog.askopenfile() #open up the file system and get the name
	else:
		zippath = filedialog.askopenfile()
	clean(zippath.name)
Example #6
0
def getFileInput():
	root = Tk()
	root.withdraw()
	wordFile = filedialog.askopenfile(title="Open Word File", mode="r", parent=root)
	if wordFile is None:
		raise SystemExit
	return wordFile
Example #7
0
def load():
	global loadfile
	global countload
	loadfile[countload] = filedialog.askopenfile()
	loadfile[countload] = str(loadfile[countload]).rsplit("/", 1)[1]
	loadfile[countload] = str(loadfile[countload]).rsplit("'", 5)[0]
	countload += 1
Example #8
0
def open_file():
	textfield.delete("1.0", END)
	file2open = filedialog.askopenfile(mode='r')
	if file2open is None:
		return
	text2open = file2open.read()
	textfield.insert("1.0", text2open)
Example #9
0
def load(num):
	global loadfile
	loadfile[num] = filedialog.askopenfile()
	if loadfile[num] != None:
		if num == 1:
			loadbutton1.config(bg = "#33FFFF")
		if num == 2:
			loadbutton2.config(bg = "#33FFFF")
		if num == 3:
			loadbutton3.config(bg = "#33FFFF")
		if num == 4:
			loadbutton4.config(bg = "#33FFFF")
		if num == 5:
			loadbutton5.config(bg = "#33FFFF")
		if num == 6:
			loadbutton6.config(bg = "#33FFFF")
		if num == 7:
			loadbutton7.config(bg = "#33FFFF")
		if num == 8:
			loadbutton8.config(bg = "#33FFFF")
		if num == 9:
			loadbutton9.config(bg = "#33FFFF")
		if num == 10:
			loadbutton10.config(bg = "#33FFFF")
		loadfile[num] = str(loadfile[num]).rsplit("/", 1)[1]
		loadfile[num] = str(loadfile[num]).rsplit("'", 5)[0]
 def ChargerJeu(self):
     self.partie.historique = ""
     self.historique.delete(1.0,END)
     fileName = filedialog.askopenfile(filetypes=[("Save Games", "*.sav")])
     self.partie.charger(fileName.name)
     self.interface_damier.ActualiserPieces(True,False)
     self.CalculPointage()
Example #11
0
    def handleOpen(self, event = None):
        global width, height

        # Einlesen der Daten
        file = askopenfile(title = "Öffnen...",
            defaultextension = ".cells",
            filetypes = [("Plaintext-Dateien (*.cells)", "*.cells")])
        f = open(file.name, "r")
        content = f.read()
        f.close()
        # Datei in ihre Zeilen zerlegen
        lines = content.strip().split("\n")
        # Whitespace-Zeichen entfernen
        lines = list(map(lambda line: list(line.strip()), lines))
        # Alle Kommentar-Zeilen entfernen, die mit ! beginnen
        data = list(filter(lambda line: line[0] != "!" if len(line) > 0 else True, lines))
        
        # Aktualisieren von Breite und Höhe
        # (Es werden zwei Zellen Rand auf allen Seiten hinzugefügt)
        height = len(data) + 4
        width = max(list(map(lambda line: len(line), data))) + 4
        self.draw_grid()

        # eingelesene Daten übernehmen
        self.grid = [[0 for y in range(height)] for x in range(width)]
        self.init_grid = [[0 for y in range(height)] for x in range(width)]
        for y in range(len(data)):
            for x in range(len(data[y])):
                if data[y][x] != '.':
                    self.init_grid[x+2][y+2] = 1
        self.handleReset()
Example #12
0
File: gui.py Project: joeliven/lfd
    def EXP_play_recreates(self, event):
        try:
            f = filedialog.askopenfile(mode='r', defaultextension=".csv")
            if f is None: # askopenfile return `None` if dialog closed with "cancel".
                return
            path_filenames = list()
            for line in f:
                fname = line.rstrip()
                print("fname is: " + str(fname))
                path_filenames.append(line.rstrip())
        finally:
            f.close()

        print("after finally block")
        # colors = ["red", "blue", "green"]
        colors = ["red", "red", "red"]
        c = 0
        for path_file in path_filenames:
            print("before EXP_open_path_from_file")
            self.EXP_open_path_from_file(path_file)
            print("after EXP_open_path_from_file")

            print("before EXP_replay_path_from_file")
            self.EXP_replay_path_from_file(colors[c%3])
            print("after EXP_replay_path_from_file")
            input("press to play next")
            # time.sleep(2)
            c += 1
            if c%1 == 0:
                self.do_clear_canvas()
Example #13
0
    def load(self, simFile=None):

        from tkinter import Tk
        from tkinter.filedialog import askopenfile
        Tk().withdraw()

        if simFile is None:
            simFile = askopenfile(mode="rb", filetypes=[("Newton's Laboratory Simulation File", ".sim")])
            if simFile is None:
                return

        data = pickle.load(simFile)

        for group in data:
            for obj in group:
                obj.simulation = self
                if isinstance(obj, Point):
                    print(obj.displacement)

        self.bodies, self.constraints = data
        self.planet = self.bodies[0]

        for d in data:
            for x in d:
                print(x.__dict__)
def main():
	root = Tk()
	root.withdraw()
	with filedialog.askopenfile(mode = "r", parent = root) as inputData:
		students = []
		for line in inputData:
			firstName, lastName = line.split(',')
			lastName = lastName.strip()
			scores = []
			scores = lastName.split('  ')	
			lastName = scores.pop(0)
			while '' in scores:
				scores.remove('')
			for item in scores:
				if ' ' in item:
					if ' ' in item[:1]:
						newItem = item[1:]
						scores.insert(scores.index(item), newItem)
						scores.remove(item)
						item = newItem
					if "100" in item:
						first, second = item.split(' ')
						first = first.strip()
						second = second.strip()
						scores.insert(scores.index(item), first)
						scores.insert(scores.index(item) + 1, second)
						scores.remove(item)
					else:
						scores[scores.index(item)] = item.replace(' ', '')
			students.append(Student(firstName, lastName, scores))
		students = sortList(students)	
		longestNameLen = findLongestName(students)
		output(students, longestNameLen, os.path.basename(inputData.name))
Example #15
0
 def load(self):
     fname = filedialog.askopenfile(parent=self, mode='rb', title='Choose a file', initialdir="./data")
     self.db.load(fname.name)
     for canvas in self.canvasi:
         self.menubar.remove_item(canvas.name)
         canvas.delete("all")
         canvas.destroy()
     self.canvasi = []
     for name in self.db.names:
         num = 0
         canv = Canv(self, name)
         self.canvasi.append(canv)
         self.canvas_switch(name)
         self.menubar.add_button("show", name, self.canvas_switch)
         for node in self.db.nodes[name]:
             cur = int(node[-1])
             if cur > num:
                 num = cur
             n = {}
             n[node] = {}
             n[node]["tags"] = self.db.tags[node].copy()
             n[node]["text"] = self.db.text[node]
             n[node]["coords"] = self.db.coords[node]
             n[node]["links"] = self.db.links[node].copy()
             canv.insert_sticker(node, n)
         for i in range(num):
             noname = numerate("Node")
         for sticky in canv.stickies:
             for other in canv.stickies[sticky].links:
                 canv.stickies[sticky].connect2box(other, True)
 def restaureDico(self):
     """Restauration du dictionnaire pour pourvoir lire et écrire dedans"""
     fiSource = askopenfile(filetypes=[("Texte", ".txt"), ("Tous", "*")])
     ligneListe = fiSource.readlines()
     for ligne in ligneListe:
         champsValeur = ligne.split()
         self.dico[champsValeur[0]] = champsValeur[1]
     fiSource.close()
Example #17
0
File: peach.py Project: v4iv/Peach
def open_file():
    global filename
    file = askopenfile(parent=root, title='Open File')
    filename = file.name
    data = file.read()
    text_area.delete(0.0, END)
    text_area.insert(0.0, data)
    file.close()
Example #18
0
 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)
Example #19
0
 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)
Example #20
0
 def handleNotification( self, notification ) :
     if notification.getName( ) == Messages.FIND_FILES :
         vo = notification.getBody()
         dfile = filedialog.askopenfile( mode='r', title=vo.msg )
         if dfile != None :
             vo.path = dfile.name
             vo.entry.delete( 0, END )
             vo.entry.insert( 0, vo.path )
Example #21
0
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.')
Example #22
0
def openfile():
  if (sys.version_info[:2] < (3,0)):
    file = tkFileDialog.askopenfile(parent=root,mode='r',title='Choose a file')
  else:
    file = filedialog.askopenfile(parent=root,mode='r',title='Choose a file')
  data = file.readlines()
  file.close()
  data = [dt.rstrip() for dt in data]
  lb_pass(data)
Example #23
0
def open_command():
    file = filedialog.askopenfile(parent=root,mode='rb',title='Select a file')
    global currentFile 
    currentFile = file.name
    if file != None:
        root.title(file.name)
        contents = file.read()
        textPad.insert('1.0',contents)
        file.close()
Example #24
0
 def restaure(self):
     "restaurer le dictionnaire à partir d'un fichier de mémorisation"
     # La fonction ci-dessous renvoie un objet-fichier ouvert en lecture :
     ofi =askopenfile(filetypes=[("Texte",".txt"),("Tous","*")]) 
     lignes = ofi.readlines()
     for li in lignes:
         cv = li.split()       # extraction de la clé et la valeur corresp.
         self.dico[cv[0]] = cv[1]
     ofi.close()
def file_open():
    a=messagebox.askyesno(title="GUARRENTY",message="Are You Sure To Open The File")
    showinfo("INFO","Retrive from location where you saved")
    if a==True:
        open_file=filedialog.askopenfile(parent=root,mode='rb',title="SELECT FILE TO BE OPENED")
    if open_file!=None:
        contents=open_file.read()
        texteditor.insert('1.0',contents)
        open_file.close()
    def _load_data(self):
        self.load_data.clear()
        load = tkd.askopenfile()
        if not load:
            return False

        for line in load:
            self.load_data.append(line.rstrip())
        load.close()
Example #27
0
 def From(self):
     self.From = askopenfile(filetypes=[("All","*.ico;*.png;*.jpg;*.bmp,*.dib;*.gif;*.jpeg;*.jfif;*.jpe;*.tiff;*.tif"),
                                     ("fichiers PNG","*.png"),
                                    ("Monochrome Bitmap","*.bmp;*.dib"),
                                    ("fichiers GIF","*.gif"),
                                    ("fichiers JPEG","*.jpg;*.jpeg;*.jfif;*.jpe)"),
                                    ("fichiers TIF","*.tif;*.tiff"),
                                     ("All","*.*"),
                                    ],title="Selectionne le fichier a convertir",initialdir=os.getcwd()[0:3])
Example #28
0
    def load_file(self):
        fname = askopenfile(mode='r', filetypes=([("Cascading Style Sheet Document", "*.css")]))
        self.file_handle = fname

        if fname:
            self.apply_button["state"] = "enabled"      # Enables other button after successful
            self.save_button["state"] = "enabled"       # file load
            self.change_text(fname.read())
            self.parse_file(fname)
Example #29
0
	def ouvrir_ficher(self):
		"""Fonction d'ouverture de fichier(ouverture seulement) """
		fichier = filedialog.askopenfile(parent=self, title="Ouvrir un mobile")
		# Si on a bien charger un fichier
		if fichier:
			test = self.selection_mode(fichier)
			if test == 1:
				self.afficher_arbre()
			else :
				fichier.close()
Example #30
0
 def loadref(self):
     f = filedialog.askopenfile(mode='r', **self.file_opt_ref)
     if not f: return
     for line in f:
         line = line.split('#')[0]
         if line.startswith('a') or line.startswith('b') or line.startswith('c') or line.startswith('g'):
             name, value = line.split('=')
             name, value = name.strip(), value.strip()
             self.coeff0[name] = float(value)
     self.updateCanvas()
Example #31
0
from tkinter import messagebox
from tkinter import filedialog
from tkinter import colorchooser

messagebox.showinfo(title='A Friendly Message', message='Hello, Tkinter!')

messagebox.askyesno(title='Hungry?', message='Do you want SPAM?')

filename = filedialog.askopenfile()
print(filename.name)

colorchooser.askcolor(initialcolor='#FFFFFF')
Example #32
0
def openFile():
    mLabel4 = Label(root, text="green").pack()
    toImport = filedialog.askopenfile(mode='r')
    return 1
Example #33
0
def cmd2():
    a = askopenfile()
Example #34
0
def SelectKnowExcelFile():
    myFormats = [('Excel','*.xls;*.xlsx')]
    fileSelected = filedialog.askopenfile(mode='r', filetypes=myFormats).name
    SVExcelFile.set(fileSelected)
Example #35
0
def open_file():
    file = askopenfile(mode='r', filetypes=[('Python Files', '*.py')])
    if file is not None:
        content = file.read()
        print(content)
Example #36
0
def selectFile():
    global _zip
    _zip = filedialog.askopenfile(initialdir=r'C:\Users')
    file = tk.Label(win, text=_zip.name)
    file.grid(row=1, column=0, padx=8)
    return _zip
Example #37
0
def open_file():
    gradeFile = askopenfile(mode='r', filetypes=[('Python Files', '*.py')])
    if gradeFile is not None:
        global content
        content = gradeFile.read()
def send_files(window):
    """
    This function sends a file to a selected client
    :param window: Tkinter window object
    :return: None
    """
    try:
        connection_num = int(input("select a connection> "))  # gets the desired connection from the user
        if connection_num <= -1:  # Checks if the number is valid
            print("Enter a positive number")
            raise Exception("Negative number given")
        conn = all_connections[connection_num]  # Gets the connection object from the connections list
    except ValueError:
        print("Enter a Number")
        return  # Returns to the interactive prompt
    except IndexError:
        print("Enter a number within the range of connections numbers")
        return  # Returns to the interactive prompt
    except Exception("Negative number given"):
        return  # Returns to the interactive prompt
    win_or_path = input("Do you want to enter the path(p or path) or select from a dialog(d or dialog)?\nYour answer: ")
    if win_or_path.lower() == "p" or win_or_path.lower() == "path":
        path = input("Enter the path: ")
        if not os.path.exists(path):  # Checks if the file specified exists
            print("File not found!")
            return  # Returns to the interactive prompt
        if not os.path.isfile(path):  # Checks if the file specified is a file and not a folder
            print("This is not a file!")
            return  # Returns to the interactive prompt
        if os.stat(path).st_size > 9000009000:  # Checks if the file size is within the size limit
            print("File is too big! the maximum size is 9 GB")
            return  # Returns to the interactive prompt
        file = open(path, "r")
        file_content = file.read()
        file.close()
        msg = " efile " + str(os.path.basename(path)) + " endname " + file_content
        file_msg = f"{len(msg):<{HEADERSIZE}}" + " efile " + str(os.path.basename(path)) + " endname " + file_content
        conn.send(bytes(file_msg, "utf-8"))
        confirm_msg = ""
        is_new = True
        while True:
            try:
                msg = conn.recv(16)
            except ConnectionResetError:
                print("Connection has been closed by the client")
                return
            if is_new:
                '''
                This if statement checks if this a new message. if true we expect to the header of the message,
                which has the length of the message inside
                '''
                try:
                    response_len = int(msg[:HEADERSIZE])
                except ValueError:
                    print("Error while getting the command length")
                    continue
                is_new = False
            confirm_msg += msg.decode("utf-8")
            if len(confirm_msg) - HEADERSIZE == response_len:
                print(confirm_msg[HEADERSIZE:])
                break
        return
    elif win_or_path.lower() == "d" or win_or_path.lower() == "dialog":
        if platform.system() == "Windows":
            window.file = filedialog.askopenfile(parent=win, initialdir=f"C:\\Users\\{getpass.getuser()}\\Documents", title="Select File")
Example #39
0
def mfileopen():
    root.file = filedialog.askopenfile()
    label = Label(text=root.file.name)
    label.pack()
    print(root.file.name)
    se1.called(root.file.name)
Example #40
0
def openFile():
    f = filedialog.askopenfile(mode='r')
    t = f.read()
    text.delete(0.0, END)
    text.insert(0.0, t)
Example #41
0
def askopenfile(self, selected_file):
    file = filedialog.askopenfile(mode='r', **self.file_opt)
    if file is not None:
        selected_file.set(file.name)
Example #42
0
 def browse_program():
     file = fd.askopenfile(initialdir="/", title="Select file", filetypes=(("exe files", "*.exe"), ("all files", "*.*")))
     if file:
         program.insert(0, file.name)
Example #43
0
load_dotenv()

import tkinter as tk
from tkinter import filedialog
from utils import getData, findIndex, formatMessage, sendUrl
from twilio.rest import Client

FROM_PHONE = os.environ.get('FROM_PHONE')
ACCOUNT_SID = os.environ.get('ACCOUNT_SID')
ACCOUNT_TOKEN = os.environ.get('ACCOUNT_TOKEN')

root = tk.Tk()
root.withdraw()

filePath = (filedialog.askopenfile(filetypes=[('Excel file',
                                               '.xlsx .csv')])).name
data = getData(filePath)
sells = []


def sendMsg():
    client = Client(ACCOUNT_SID, ACCOUNT_TOKEN)
    for s in sells:
        s['msg'] = formatMessage(s)
        client.messages.create(to='whatsapp:+521' + str(s['phone']),
                               from_=FROM_PHONE,
                               body=s['msg'])


def init():
    for d in data:
Example #44
0
def Find():
    filename = filedialog.askopenfile()
    print('Selected:', filename)
def upload_data_function():
    global csv_file_path
    tkinter.Tk().withdraw()
    in_path = filedialog.askopenfile()
    csv_file_path = in_path.name
    heading_extraction_from_csv(csv_file_path)
Example #46
0
            CentError[CentriodIndex[i]]['2'] += 1
        else:
            CentError[CentriodIndex[i]]['4'] += 1
    #Type and Error rate of each cluster is identified
    for i in range(K):
        Total = CentError[i]['2'] + CentError[i]['4']
        CentError[i][
            'type'] = 2 if CentError[i]['2'] >= CentError[i]['4'] else 4
        CentError[i]['error'] = 1.00 * CentError[i]['4'] / Total if CentError[
            i]['2'] >= CentError[i]['4'] else 1.00 * CentError[i]['2'] / Total
        TotalError += CentError[i]['error']
    return CentError, TotalError


#For getting the file
Filename = filedialog.askopenfile(mode='r')
rows, data, classVar = readfile(Filename.name)
Path = File[:k + 1]
numRows, numCols = numpy.array(data).shape

#Number of rows and columns in the data
print(numRows, numCols)

#Number of iterations if the threshold condition is not satisfied is set to 10
itermax = 10
loopiter = 0
outputFile = open(Path + "KmeansOutput.csv", "w")
outputFile.write("K,Iteration,BestTauLimit,ErrorRate\n")
BestCentroidIndex = []
#Algorithm is run for K=2...5 20 Iterations each and for threshold limit 0 to 4
for K in range(2, 6):
Example #47
0
 def open(self):
     """ Open a file """
     logger.debug("Popping Open browser")
     return filedialog.askopenfile(**self.kwargs)
Example #48
0
def open_file():
    blank.delete("1.0",END)
    file = askopenfile(mode='r',filetypes=[('text files','*.txt')])
    if file is not None:
        text = file.read()
        blank.insert("1.0",text)
Example #49
0
    if len(c)!=0:
        CODE.append(c)

REGEX=''
for j in CODE:
    REGEX= j+'[0-9]{4,11}\-.{8}?'+'|'+j+'[0-9]{4,11}.?'+'|'+REGEX

REGEX=REGEX[:-1]




root = tkinter.Tk()
root.withdraw()

file = filedialog.askopenfile(parent=root,mode='rb',title='Choose a file')
if file != None:
    data = file.read()
    file.close()
    print("I got %d bytes from this file." % len(data))

    

df=pd.read_excel(file.name, sheet_name='URL一覧', encoding = 'utf-8')
URLS=df.loc[:,'新URL']
URLS_clean = URLS.fillna('no url')
old_code= df.loc[:,'募文番号']
code_clean=old_code.fillna('no code')
code_clean=code_clean[2:]
conn_urls=[]
new_code=[]
Example #50
0
    print_board(board)
    print('Words remaining: {num} words left.'.format(num=num_remaining))
    print('Words found: ' + (' '.join(found_words) or 'No words found, yet.'))


def print_score(players):
    """ (list of [str, int] list) -> NoneType

    Print the scores for each of the players.
    """
    for name, score in players:
        print('  ' + str(score).rjust(3) + '\t' + name)


# Load the words list.
words_file = askopenfile(mode='r', title='Select word list file')
words = a3.read_words(words_file)
words_file.close()

# Load the board.
board_file = askopenfile(mode='r', title='Select board file')
board = a3.read_board(board_file)
board_file.close()

found_words = []

players = get_players_list()

play_game(players, board, words)
print_score(players)
Example #51
0
def open(Event = None):
    files = filedialog.askopenfile(filetypes = (("Text files","*.txt"),("all files","*.*")), title = "Select a File")
    doc = files.name
    root.title(f"{os.path.basename(doc)} - TextBOX")
    text.insert(INSERT, files.read())
Example #52
0
def open_csv():
    print("Open CSV pressed")
    csv_file = filedialog.askopenfile(initialdir="/",
                                      title="Select .csv file",
                                      filetypes=(("csv files", "*.csv"), ))
    return csv_file.name
Example #53
0
def load():
    file=filedialog.askopenfile(mode="r",filetype=[('text files','*.txt')])
    if file is not None:
        content= file.read()
        entry.insert(INSERT,content)
Example #54
0
def GetFile():
    file = filedialog.askopenfile()
    return file
Example #55
0
 def load_config(self):
     f = filedialog.askopenfile()
     if not f:
         return
     data = json.load(f)
     self._gui.deserialize(data)
def chooseFile():
    inputFile = filedialog.askopenfile(mode="r")
    global fileName
    fileName = inputFile.name
Example #57
0
 def choose_file(entry):
     entry.delete(0, tk.END)
     entry.insert(0, askopenfile().name)
def open():
    file = filedialog.askopenfile(parent=window, mode='r')
    if file != None:
        lines = file.read()
        text.insert('1.0', lines)
        file.close()
 def open_file(self):
     f = filedialog.askopenfile(initialdir="c://",
                                title="Select file",
                                filetypes=(("text file", "*.txt"),
                                           ("all files", "*.*")))
Example #60
0
def OpenFile():
    print("Clicked open file..!")
    file = fd.askopenfile(mode='r', filetypes=[('Python Files', '*.py')])
    if file is not None:
        content = file.read()
        print(content)