bstraehle commited on
Commit
1fede0d
·
verified ·
1 Parent(s): 5ac2495

Update util.py

Browse files
Files changed (1) hide show
  1. util.py +6 -6
util.py CHANGED
@@ -13,18 +13,18 @@ def get_questions(file_path):
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.to_string()
28
 
29
  def get_final_answer(model, question, answer):
30
  prompt_template = """
 
13
  return result
14
 
15
  def read_file(file_path):
16
+ df = None
17
+
18
  ext = os.path.splitext(file_path)[1].lower()
19
 
 
 
20
  if ext == ".csv":
21
+ df = pd.read_csv(file_path)
22
  elif ext in (".xls", ".xlsx"):
23
+ df = pd.read_excel(file_path)
24
  elif ext in (".json", ".jsonl"):
25
+ df = pd.read_json(file_path)
26
 
27
+ return "" if df is None else df.to_string()
28
 
29
  def get_final_answer(model, question, answer):
30
  prompt_template = """