bstraehle commited on
Commit
03fc65f
·
verified ·
1 Parent(s): 1081c8c

Update util.py

Browse files
Files changed (1) hide show
  1. util.py +14 -0
util.py CHANGED
@@ -12,6 +12,20 @@ def get_questions(file_path):
12
 
13
  return result
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  def get_final_answer(model, question, answer):
16
  prompt_template = """
17
  You are an expert question answering assistant. Given a question and an initial answer, your task is to provide the final answer.
 
12
 
13
  return result
14
 
15
+ def read_file(file_path):
16
+ ext = os.path.splitext(file_path)[1].lower()
17
+
18
+ result = ""
19
+
20
+ if ext == '.csv':
21
+ result = pd.read_csv(file_path)
22
+ elif ext in ('.xls', '.xlsx'):
23
+ result = pd.read_excel(file_path)
24
+ elif ext in ('.json', '.jsonl'):
25
+ result = pd.read_json(file_path)
26
+
27
+ return result
28
+
29
  def get_final_answer(model, question, answer):
30
  prompt_template = """
31
  You are an expert question answering assistant. Given a question and an initial answer, your task is to provide the final answer.