Lashtw commited on
Commit
0c3af54
·
verified ·
1 Parent(s): 095443a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -1,17 +1,20 @@
1
- import pandas as pd
2
  import gradio as gr
3
 
4
- # Load the CSV file (adjust the file path as necessary)
5
- data = pd.read_csv("桌遊答案CSV檔.csv")
 
 
 
 
6
 
7
  def query_data(clue_number):
8
  try:
9
  clue_number = int(clue_number)
10
- row = data[data['蛛絲馬跡'] == clue_number]
11
- if not row.empty:
12
- suspect = row['嫌疑犯'].values[0]
13
- direct_evidence = row['直接證據'].values[0]
14
- indirect_evidence = row['間接證據'].values[0] if not pd.isna(row['間接證據'].values[0]) else "無間接證據"
15
  return f"嫌疑犯: {suspect}\n直接證據: {direct_evidence}", indirect_evidence, gr.update(visible=True)
16
  else:
17
  return "未找到相關資料,請檢查蛛絲馬跡號碼是否正確。", "", gr.update(visible=False)
 
 
1
  import gradio as gr
2
 
3
+ # Replace the CSV data loading with in-memory data
4
+ data = [
5
+ {"蛛絲馬跡": 11, "嫌疑犯": "16造型師", "直接證據": "RHS", "間接證據": "SSS"},
6
+ {"蛛絲馬跡": 12, "嫌疑犯": "17設計師", "直接證據": "XYZ", "間接證據": "TTT"},
7
+ # Add more rows as needed
8
+ ]
9
 
10
  def query_data(clue_number):
11
  try:
12
  clue_number = int(clue_number)
13
+ row = next((item for item in data if item['蛛絲馬跡'] == clue_number), None)
14
+ if row:
15
+ suspect = row['嫌疑犯']
16
+ direct_evidence = row['直接證據']
17
+ indirect_evidence = row['間接證據'] if row['間接證據'] else "無間接證據"
18
  return f"嫌疑犯: {suspect}\n直接證據: {direct_evidence}", indirect_evidence, gr.update(visible=True)
19
  else:
20
  return "未找到相關資料,請檢查蛛絲馬跡號碼是否正確。", "", gr.update(visible=False)