Spaces:
Runtime error
Runtime error
File size: 1,218 Bytes
18b8552 6c311bc 18b8552 6c311bc 18b8552 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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()
|