ELVISIO commited on
Commit
9748612
·
verified ·
1 Parent(s): fe87cec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -5,19 +5,23 @@ import json
5
  # 读取Excel文件
6
  def read_excel(file_path):
7
  df = pd.read_excel(file_path)
8
- # 提取第一列的数据
9
- first_column_data = df.iloc[:, 6].tolist()
10
- return first_column_data
 
11
 
12
  # 生成问卷调查界面
13
- def generate_survey(data):
14
- # 将数据转换为Markdown格式
15
- markdown_text = "\n".join([f"- {item}" for item in data])
16
-
17
  # 创建Gradio界面
18
  with gr.Blocks() as demo:
19
  gr.Markdown("## 问卷调查")
20
- gr.Markdown(markdown_text)
 
 
 
 
 
 
21
 
22
  # 创建一个文本输入框用于打分
23
  score = gr.Textbox(label="请打分 (1-5)", placeholder="输入1到5之间的数字")
@@ -52,10 +56,10 @@ def generate_survey(data):
52
  def main():
53
  # 读取Excel文件
54
  file_path = "survey_data.xlsx" # 替换为你的Excel文件路径
55
- data = read_excel(file_path)
56
 
57
  # 生成问卷调查界面
58
- demo = generate_survey(data)
59
 
60
  # 启动Gradio应用
61
  demo.launch()
 
5
  # 读取Excel文件
6
  def read_excel(file_path):
7
  df = pd.read_excel(file_path)
8
+ # 提取 Output 和 Initial Output 列的第一行数据
9
+ output_str = df["Output"].iloc[0] # 第一行 Output 列的值
10
+ initial_output_str = df["Initial Output"].iloc[0] # 第一行 Initial Output 列的值
11
+ return output_str, initial_output_str
12
 
13
  # 生成问卷调查界面
14
+ def generate_survey(output_str, initial_output_str):
 
 
 
15
  # 创建Gradio界面
16
  with gr.Blocks() as demo:
17
  gr.Markdown("## 问卷调查")
18
+
19
+ # 将 Output 和 Initial Output 列的数据显示在文本区域中
20
+ gr.Markdown("### Output")
21
+ output_text = gr.Textbox(value=output_str, label="Output", lines=2, interactive=False)
22
+
23
+ gr.Markdown("### Initial Output")
24
+ initial_output_text = gr.Textbox(value=initial_output_str, label="Initial Output", lines=2, interactive=False)
25
 
26
  # 创建一个文本输入框用于打分
27
  score = gr.Textbox(label="请打分 (1-5)", placeholder="输入1到5之间的数字")
 
56
  def main():
57
  # 读取Excel文件
58
  file_path = "survey_data.xlsx" # 替换为你的Excel文件路径
59
+ output_str, initial_output_str = read_excel(file_path)
60
 
61
  # 生成问卷调查界面
62
+ demo = generate_survey(output_str, initial_output_str)
63
 
64
  # 启动Gradio应用
65
  demo.launch()