Update util.py
Browse files
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 |
-
|
22 |
elif ext in (".xls", ".xlsx"):
|
23 |
-
|
24 |
elif ext in (".json", ".jsonl"):
|
25 |
-
|
26 |
|
27 |
-
return
|
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 = """
|