Google Sheets Api, python. How to access specific cell data

  google-sheets, python

I am currently doing project for college where I need to create a basic banking system using google sheets & python. I have successfully been able to add customer data & check data is correct. However I am looking to see how i could check a specific customer balance depending on their email address.

Email Address Full Name Password Balance
[email protected] brian Smith Password1234 500

Here is my code.

def emailcheck(emailinput):
"""
Email validator function
"""
try:
valid = validate_email(emailinput)
emailinput = valid.email
return emailinput
except EmailNotValidError as e:
print("The email you provided is not valid please try againn")

def registerEmail():
"""
This fucntion checks the email address is correct
while loop will continue until a valid emai is input
"""

print("Welcome to retro bank As a new customern" +
    "Please complete the following fileds to sign up for an accountn")

while True:
    try:
        global email
        email = input("Please enter your email address: ")
        einput = emailcheck(email)
        if einput != email:
            raise ValueError(
                "Please enter a valid email" +
                f" you entered: {email}"
            )
        else:
            regDetails()
            return email
    except ValueError as e:
        print(f"Invalid data: {e}, please try again.n")

def regDetails():

sheet = SHEET.worksheet("customer-data")
new_cust = []
bonus = 500


while True:
    name = input("Please enter your full name: ")
    password = input("Please enter your password: ")
    if name == "":
        print("Name is required")
    elif password == "":
        print("Password Required")
    else:
        new_cust.append(email)
        new_cust.append(name)
        new_cust.append(password)
        new_cust.append(bonus)
        sheet.append_row(new_cust)
        print("WELCOME TO RETRO BANK !" +
        " As a new customer you will receive £500 joining bonus")
        login()
        break

def login():
"""
This fucntion will allow the exisiting user
log into their bank account
"""
global email_ver
global details
global password
global balances
email_ver = SHEET.worksheet("customer-data")
details = email_ver.col_values(1)
password = email_ver.col_values(3)
balances = email_ver.col_values(4)
user = []

while True:
    ename = input("Please enter your email address: ")
    epass = input("Please enter your password: ")
    if ename  == "":
        print("Name is required")
    elif epass == "":
        print("Password Required")
    else:
        break

user.append(ename)
user.append(epass)

found = 0

for i in zip(details, password):
    if i == tuple(user):
        found = 1
        print("Successfully Verified")
        mainDash(user)
        return found
if found == 0:
    print("The username or the password you provided might be wrong.n")
    login()
    return found

def mainDash(user):
print(user)
print("WELCOME")

for i in (details):
    if i == user:
        print()

Source: Python Questions

LEAVE A COMMENT