#Netflix type system demo - FakeFlix
import csv
import sys
import pandas as pd
def main():
menu()
def menu():
print("************Welcome to Movie Recomender System**************")
print()
choice = input("""
A: Add a user
B: List all user
C: Suggest a movie
D: List all movie
Q: Logout
Please enter your choice: """)
if choice == "A" or choice =="a":
register()
elif choice == "B" or choice =="b":
displayUser()
elif choice == "C" or choice =="c":
suggestMovie()
elif choice == "D" or choice =="d":
displayMovie()
elif choice=="Q" or choice=="q":
sys.exit()
else:
print("You must only select either A or B")
print("Please try again")
menu()
def register():
#user is prompted to input all the required fields
print("Enter first name")
firstname=input()
print("Enter lastname")
lastname=input()
print("Enter rating")
rating=input()
print("Your unique username is", firstname+lastname)
global username
username=firstname+lastname
with open('users.txt','a') as users:
usersWriter=csv.writer(users)
usersWriter.writerow([username,firstname,lastname,rating])
print("User has been added succesfully")
users.close()
menu()
def displayUser():
df = pd.read_csv("users.txt",delimiter=',')
df.to_csv('users.csv')
print(df.head())
menu()
def suggestMovie():
df = pd.read_csv("movie.csv",delimiter=',')
#df.to_csv('movie.csv')
print(df.head())
menu()
global username
def displayMovie():
#open the file
with open("movie.csv","r") as f:
#prompt the user to enter the desired title that they are searching for
rating=input("Enter the RATING you are after *and we'll show you films that match*:")
#call up on the csv reader (this will allow us to work with the file and do clever stuff!)
fReader=csv.reader(f)
#for reach row that is read by the reader
for row in fReader:
#and for each field in that row (this feature is automated by the reader)
for field in row:
#if the field is equal to the rating that you are looking for
if rating in field: #this looks for title or any part of title in the field (not necessarily a perfect solution)
print("Searching file ....please wait")
print("Found:", row)
print("This is film no:", row[0])
choice=input("""Would you like to view any of these films?
Y: Yes
N: No, thanks
Please enter your choice:""")
if choice=="Y" or choice=="y":
print("We are taking you to the WATCH FILMS menu - ratings are displayed next to films")
suggestMovie()
elif choice=="N" or choice=="n":
sys.exit()
#print(df.head())
#the program is initiated, so to speak, here
main()