The CSV file is called Disneyland_reviews.csv and contains thousands of reviews about
Disneyland parks around the world. Disneyland_reviews.csv contains the following
information, with each row in the file representing a single review:
Column Description Type
2
Academic Registry 2024-25
Review_ID Just a unique identifier, contains
no useful
information
Int
Rating The score given by the reviewer
out of 5.
Int
Year_Month The year and month the review
was made.
String
Reviewer_Location Where the reviewer is from. String
Branch Which Disneyland Park is being
reviewed
String
It is recommended that you familiarise yourself with the content of the data file before
attempting the remainder of this assessment.
1. First, when running the program, it should display the following (take note of the
annotation):
--------------------------
Disneyland Review Analyser
--------------------------
2.Read in the data from the provided CSV file, said data should be stored in a list.
The program should confirm to the user when it has finished reading in the dataset.
It should also tell the user how many rows are in the
dataset.
3. Output the following to the screen, this will act as a menu. The user should then
be able to input their selection, which should be stored in a suitable
variable.
Please enter the letter which corresponds with your desired menu choice:
[A] View Data
[B] Visualise Data
[X] Exit
4.The program should confirm what the user has entered. If the user entered an
invalid menu choice, then they should be informed of their mistake.
5.The program should run continuously. Once the user has entered their choice, it
should confirm this choice and then display the menu again, asking the user for
their selection. Be careful how you implement this, the program does not need to
display the title and load in the dataset again. The program should only end if the
user indicates they wish to exit the program through the appropriate menu
choice.
6. If the user selects ‘A’ as their menu choice, the program should display the
following
sub-menu and receive the user’s choice:
Please enter one of the following options:
[A] View Reviews by Park
[B] Number of Reviews by Park and Reviewer Location
[C] Average Score per year by Park
[D] Average Score per Park by Reviewer Location
If the user selects ‘B’ as their menu choice, the program should display the
following sub-menu and receive the user’s choice:
Please enter one of the following options:
[A] Most Reviewed Parks
[B] Park Ranking by Nationality
[C] Most Popular Month by Park
7.We will now focus on the sub-menu that is displayed should the user choose ‘A’
at
the main menu.
The first sub-menu option will allow the user to see all the reviews for a specific
parca. If the user selects this option, then the program should respond by asking
which parca the user wishes to see the reviewsfor. The program should then display
all reviews for said parca.
8. The second sub-menu option will simply display the number of reviews a specific
parca has received from a given location. Both the parca and the reviewer’s location should be retrieved from the user.
Am rezolvat pana la 6, inclusiv.La punctul 7, dupa ce am scris codul, cand ii dau run, si ii spun pentru ce parc vreau sa vad, imi scrie None.(Adica n-a fost gasit nimic).
Acesta este codulUnde vezi parca, este de fapt p a r k)
import csv
def read_data(file_name):
with open(file_name, mode='r', encoding='utf-8') as file:
reader = csv.reader(file)
data = list(reader)
return data
def main():
print("--------------------------")
print("Disneyland Review Analyser")
print("--------------------------")
data = read_data('Disneyland_reviews.csv')
print(f"Finished reading dataset with {len(data) - 1} rows.") # Subtracting header row
while True:
print("\nPlease enter the letter which corresponds with your desired menu choice:")
print("[A] View Data")
print("[B] Visualise Data")
print("[X] Exit")
choice = input(). strip(). upper()
if choice not in ['A', 'B', 'X']:
print("Invalid choice, please try again.")
continue
print(f"You selected: {choice}")
if choice == 'X':
break
if choice == 'A':
view_data_submenu()
elif choice == 'B':
visualise_data_submenu()
def view_data_submenu():
print("\nPlease enter one of the following options:")
print("[A] View Reviews by Park")
print("[B] Number of Reviews by Park and Reviewer Location")
print("[C] Average Score per year by Park")
print("[D] Average Score per Park by Reviewer Location")
choice = input(). strip(). upper()
if choice == 'A':
parca = input("Which parca would you like to see reviews for? ")
view_reviews_by_park(parca)
elif choice == 'B':
location = input("Enter the reviewer location: ")
parca = input("Enter the parca: ")
number_of_reviews(parca, location)
# Add other options as needed
def visualise_data_submenu():
print("\nPlease enter one of the following options:")
print("[A] Most Reviewed Parks")
print("[B] Park Ranking by Nationality")
print("[C] Most Popular Month by Park")
# Add functionality for these options
def view_reviews_by_park(parca):
# Logic to display reviews for the specified parca
pass
def number_of_reviews(parca, location):
# Logic to count reviews for the specified parca and location
pass
if __name__ == "__main__":
main()
AndreiMircea22 întreabă: