bot upgraded
This commit is contained in:
33
hotels/booking_analyzer.py
Normal file
33
hotels/booking_analyzer.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
import pandas as pd
|
||||
|
||||
# Load the JSON file
|
||||
file_path = '../../modules/analyzed_9.json'
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
|
||||
# Process the data into a structured format
|
||||
reservations = []
|
||||
for booking in data:
|
||||
for guest in booking.get("guests", []):
|
||||
reservations.append({
|
||||
"Reservation ID": booking.get("id"),
|
||||
"Hotel Name": booking.get("hotelName"),
|
||||
"Room Number": booking.get("roomNumber"),
|
||||
"Room Type": booking.get("roomTypeName"),
|
||||
"Check-in": booking.get("from"),
|
||||
"Check-out": booking.get("until"),
|
||||
"Status": booking.get("checkInStatus"),
|
||||
"Price": booking.get("reservationPrice"),
|
||||
"Discount": booking.get("discount"),
|
||||
"Guest Name": f"{guest.get('lastName', '')} {guest.get('firstName', '')} {guest.get('middleName', '')}".strip(),
|
||||
"Guest Birthdate": guest.get("birthDate"),
|
||||
"Guest Phone": guest.get("phone"),
|
||||
"Guest Email": guest.get("email"),
|
||||
})
|
||||
|
||||
# Convert to DataFrame for better visualization
|
||||
df_reservations = pd.DataFrame(reservations)
|
||||
|
||||
# Display the structured data
|
||||
import ace_tools as tools; tools.display_dataframe_to_user(name="Structured Reservations Data", dataframe=df_reservations)
|
||||
Reference in New Issue
Block a user