Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
orionweller
commited on
Commit
•
bedf86a
1
Parent(s):
5a33a55
add index fix also
Browse files- refresh.py +7 -2
refresh.py
CHANGED
@@ -446,7 +446,8 @@ def write_out_results(item: dict, item_name: str):
|
|
446 |
elif isinstance(item, pd.DataFrame):
|
447 |
print(f"Saving {main_folder} to {main_folder}/default.jsonl")
|
448 |
os.makedirs(main_folder, exist_ok=True)
|
449 |
-
|
|
|
450 |
|
451 |
elif isinstance(item, str):
|
452 |
print(f"Saving {main_folder} to {main_folder}/default.txt")
|
@@ -492,7 +493,11 @@ def load_results(data_path):
|
|
492 |
return {file_name: load_results(os.path.join(data_path, file_name)) for file_name in all_files_in_dir}
|
493 |
|
494 |
elif data_path.endswith(".jsonl"):
|
495 |
-
|
|
|
|
|
|
|
|
|
496 |
else:
|
497 |
with open(data_path, "r") as f:
|
498 |
data = f.read()
|
|
|
446 |
elif isinstance(item, pd.DataFrame):
|
447 |
print(f"Saving {main_folder} to {main_folder}/default.jsonl")
|
448 |
os.makedirs(main_folder, exist_ok=True)
|
449 |
+
|
450 |
+
item.reset_index().to_json(f"{main_folder}/default.jsonl", orient="records", lines=True)
|
451 |
|
452 |
elif isinstance(item, str):
|
453 |
print(f"Saving {main_folder} to {main_folder}/default.txt")
|
|
|
493 |
return {file_name: load_results(os.path.join(data_path, file_name)) for file_name in all_files_in_dir}
|
494 |
|
495 |
elif data_path.endswith(".jsonl"):
|
496 |
+
df = pd.read_json(data_path, orient="records", lines=True)
|
497 |
+
if "index" in df.columns:
|
498 |
+
df = df.set_index("index")
|
499 |
+
return df
|
500 |
+
|
501 |
else:
|
502 |
with open(data_path, "r") as f:
|
503 |
data = f.read()
|