0

My question is: Once the customer selects the hotel, ask him the give feedback for the same and update the rating.csv file as per the data received.And how i update that given feed back to these file.

This is what I tried so far:

h_id=str(input("Enter Hotel_Id:"))
with open("rating.csv", "r") as fb:
    csvreader = csv.reader(fb, delimiter=",")
    for row in csvreader:
        if h_id in row[0]:
           print("Hotel Booked Sucessfully")
           f_back=float(input("Please Give Feedback of Hotel you selected outoff 5:"))

enter image description here

4
  • Your question is really unclear, can you improve it please? Commented May 14, 2020 at 12:28
  • I have update the question. Commented May 14, 2020 at 12:36
  • Thanks! Now I see what you want to do. What did you try so far? Can you post some code? Commented May 14, 2020 at 12:52
  • Bro, I have paste ma code Commented May 14, 2020 at 13:02

1 Answer 1

1

I would do it in this way:

import pandas as pd

#read the hotels table
hotels = pd.read_csv("rating.csv")

h_id=str(input("Enter Hotel_Id:"))
f_back=float(input("Please Give Feedback of Hotel you selected outoff 5:"))

hotels.loc[hotels.Hotel == h_id,"no_of_feedback" ] = hotels.loc[hotels.Hotel == h_id,"no_of_feedback" ]+1
hotels.loc[hotels.Hotel == h_id,"Feedback" ] = f_back

#store updated table
hotels.to_csv("rating.csv")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.