import csv import gradio as gr # Load the hospital data from the CSV file with open('hospital_data.csv', 'r') as f: reader = csv.DictReader(f) hospital_data = list(reader) def display_hospital_info(index): # Get the hospital data for the specified index hospital = hospital_data[index] # Format the hospital information as a string info_str = f"{hospital['Hospital Name']}\n" \ f"{hospital['Address']}\n" \ f"{hospital['Number of Hospital Beds']} Beds\n" \ f"{hospital['Number of Employees']} Employees\n" \ f"{hospital['Services']}" return info_str # Define the Gradio interface iface = gr.Interface( fn=display_hospital_info, inputs=gr.inputs.Slider(minimum=0, maximum=len(hospital_data)-1, step=1, default=0, label="Select a hospital:"), outputs=gr.outputs.Textbox(label="Hospital Information"), title="Hospital Information", description="Display information on hospitals across the United States, including the number of hospital beds, employees, services offered, and address.", theme="huggingface", layout="vertical", allow_flagging=False ) # Launch the Gradio interface iface.launch()