How to search with 2 search terms - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to search with 2 search terms (/thread-21962.html) |
How to search with 2 search terms - karsky - Oct-22-2019 Hello, I am busy trying to fix my search option but i ran into some problems. My Column names are dutch :P ID;Naam;Adres;Woonplaats Translate into ID,Name,Adress,Place of residence def zoeken means def search and def wijzigen means def edit This is a part of the function below, it works on finding a name. But when I have 2 Names of the same, i want to allow the user a second input on IDnummer so he can find the right one. This way he can edit the right data. def zoeken_op_Naam(): Naam = input("Voer een voor en achternaam in:\n") print(Naam.title()) checkNaam = open("Adressenboek.csv", "r") reader = csv.reader(checkNaam, delimiter=';') for data in reader: if Naam.title() in data: print(data) def wijzigen(): Naam = input("Voer een voor en achternaam in:\n") print(Naam.title()) CheckNaam = open("Adressenboek.csv", "r") reader = csv.reader(CheckNaam, delimiter=';') NieuwBestand = [] for data in reader: if data[1] == Naam.title(): NieuwNaam = input("Voer nieuwe naam in:\n") Naam = NieuwNaam.title() NieuwRegel = "%s,%s,%s,%s \n" %(data[0], NieuwNaam, data[2], data[3]) NieuwBestand.append(NieuwRegel) else: NieuwBestand.append(data) CheckNaam.close() CheckNaam = open("Adressenboek.csv", "w") for data in NieuwBestand: CheckNaam.write(str(data)) CheckNaam.close()Thanks, Karsky RE: How to search with 2 search terms - Larz60+ - Oct-22-2019 you may want to look at this package: https://pypi.org/project/acora/ RE: How to search with 2 search terms - karsky - Oct-23-2019 (Oct-22-2019, 06:21 PM)Larz60+ Wrote: you may want to look at this package: https://pypi.org/project/acora/ Hello im only aloud to use python3.6 basic function to get this done. |