Hi Guys,
First off, I am new to Python and coding. I do apologise if this question has already been asked. I have searched the forum board and was unable to find a thread that gave me the answer I'm looking for.
Currently writing a small bit of code that will simply query a CSV file for lets say a 'Serial Number'. I have programmed a button that will grab text that is entered in an 'input box' for the user. I now would like to use that entered text to search/query a csv file. I am stuck :(
sorry for being a noob but as mentioned - I am learning and new to Python.
I noticed I may have not explained myself properly on what I would like to achieve.
First off, I am new to Python and coding. I do apologise if this question has already been asked. I have searched the forum board and was unable to find a thread that gave me the answer I'm looking for.
Currently writing a small bit of code that will simply query a CSV file for lets say a 'Serial Number'. I have programmed a button that will grab text that is entered in an 'input box' for the user. I now would like to use that entered text to search/query a csv file. I am stuck :(

import tkinter as tk import requests import csv root = tk.Tk() #defining canvas size HEIGHT = 600 WIDTH = 800 #defined variables def get_serial(entry): print("Serial Number Has Been Entered:", entry) # # with open('testdb.csv') as csvfile: # readCSV = csv.reader(csvfile, delimiter=',') canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH) canvas.pack() #defining the background image background_image = tk.PhotoImage(file='background.png') background_label = tk.Label(root, image=background_image) background_label.place(relwidth=1, relheight=1) #defining frame position, color and size frame = tk.Frame(root, bg='light grey') frame.place(relx=0.20, rely=0.20, relwidth=0.6, relheight=0.6) #defining button position and color button = tk.Button(frame, text="Locate Device", bg='green', command=lambda: get_serial(entry.get())) button.place(relx=0.25, rely=0.8, relwidth=0.50, relheight=0.10) #Welcome Screen to db Search label = tk.Label(frame, text="Welcome to Db Search v1.0 \n written using Python", bg='red') label.place(relx=0.25, rely=0.05, relwidth=0.50, relheight=0.1) #defining label for searching the serial number label = tk.Label(frame, text="Please Enter the Serial Number") label.place(relx=0.25, rely=0.25, relwidth=0.50, relheight=0.05) #entry field for Searching via Serial number entry = tk.Entry(frame, bg='dark grey') entry.place(relx=0.25, rely=0.30, relwidth=0.50, relheight=0.05) root.mainloop()
I noticed I may have not explained myself properly on what I would like to achieve.
- User inputs 'serial number'
- Serial number is then queried against CSV file 'testdb.csv'
- Then returns the finding in a text box along with its location and model etc.