Finding a record in a database with Python

A practical tutorial on searching with FuzzyWuzzy

Photo by K8 on Unsplash
import pandas as pd
database = pd.read_csv("https://medicalprogress.dev/dummy_data/dummy_db.csv")
database
# Get input from user
name = input("Provide name: \n")
birthdate = input("Provide birthdate in format dd/mm/yyyy: \n")
# Search birthdate in database
name_database = None
for index, row in database.iterrows():
if row[1] == birthdate:
name_database = row[0]
address = row[2]
# Do fuzzywuzzy comparison
from fuzzywuzzy import fuzz
Str1 = name
Str2 = name_database
partial_ratio = fuzz.partial_ratio(Str1.lower(), Str2.lower())
if partial_ratio > 80:
print("During search based on birthdate a name match was found...")
print("Partial string ratio =", partial_ratio)
print("Was", name_database, "with birthdate", birthdate, "living on", address, "the person that you were looking for?")
else:
print("Person not found with birthdate", birthdate, "and name", name)
Provide name: 
Brown
Provide birthdate in format dd/mm/yyyy:
09/08/1939
First name in database that corresponds with input birthdate = Ms. Q. Brown
During search based on birthdate a name match was found...
Partial string ratio = 100
Was Ms. Q. Brown with birthdate 09/08/1939 living on 86 Bankside Drive, Thames Ditton,KT7 0AH the person that you were looking for?

MD and PhD. Let’s bring health and tech together.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store