quinta-feira, 12 de janeiro de 2023

Abrir arquivo (Open File)

 

Import CSV

from tkinter import *

import pandas as pd

with open('Filename.csv',newline='') as self.myfile:

            self.csv_file = csv.reader(self.myfile, delimiter=',')

 

            self.Menusyn=[]

            for i in self.csv_file:

                self.Menusyn.append(i[0])

            self.syn = list()

            for self.value in self.Menusyn:

                if self.value not in self.syn:

                    self.syn.append(self.value)

        def textnome(event):

            self.doctext = pd.read_csv("Filename.csv",encoding='utf-8')

            self.readertx = pd.DataFrame(self.doctext)

            self.nomeerrado= self.doctext.columns[0]

            self.doc_selecao = self.readertx.loc[self.readertx[self.nomeerrado] == self.Combosyn.get()]

            self.linhatx = 0

            self.frame = 4

            while self.linhatx < len(self.doc_selecao):

                       self.locali = self.doc_selecao.iloc[self.linhatx,1]

                       tk.Label(self.brachs, text = self.locali).grid(row=self.frame,column=2)

                       tk.Label(self.brachs, text = "Current name").grid(row=3,column=2)

                       self.linhatx = self.linhatx+1

                       self.frame = self.frame+1

        self.brachs = root

        self.frame = tk.Frame(self.brachs)

        self.brachs = Tk()

        self.brachs.geometry("500x100")

        tk.Label(self.brachs, text = "Nome").grid(row=1,column=1)

        self.brachs.title("Find name")

        self.Combosyn = ttk.Combobox(self.brachs, width = 30, height = 20)

        self.Combosyn.grid(row=2, column=1)

        self.syn=sorted(self.syn)

        self.Combosyn ['values']= self.syn

        self.Combosyn.bind("<<ComboboxSelected>>",textnome)

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.