Spaces:
Sleeping
Sleeping
Commit
·
9435ad1
1
Parent(s):
f88ec6e
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,9 @@ import csv
|
|
| 6 |
import pandas as pd
|
| 7 |
import ast
|
| 8 |
from datasets import load_dataset
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
data = pd.read_csv("./KB_gpt_v1.csv",index_col=0)
|
| 11 |
|
|
@@ -39,14 +42,33 @@ def get_list(disease):
|
|
| 39 |
drugs = ast.literal_eval((data[data['diseases']==str(disease)]["Drug type: Drugs"]).iloc[0])
|
| 40 |
advices = ast.literal_eval((data[data['diseases']==str(disease)]["Advices"]).iloc[0])
|
| 41 |
return sympto,investigations,drugs,advices
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
#
|
|
|
|
|
|
|
| 44 |
def save_data(disease,symp_data,invest_data,drug_data,advice_data):
|
| 45 |
user = ""
|
| 46 |
for username, logged_in in logged_in_users.items():
|
| 47 |
if logged_in:
|
| 48 |
user = username
|
| 49 |
print("In save:",user)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
try:
|
| 51 |
print("In try")
|
| 52 |
with open("./demo1.csv", mode="w", newline="") as csvfile:
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
import ast
|
| 8 |
from datasets import load_dataset
|
| 9 |
+
from huggingface_hub import HfApi, HfFolder
|
| 10 |
+
|
| 11 |
+
|
| 12 |
|
| 13 |
data = pd.read_csv("./KB_gpt_v1.csv",index_col=0)
|
| 14 |
|
|
|
|
| 42 |
drugs = ast.literal_eval((data[data['diseases']==str(disease)]["Drug type: Drugs"]).iloc[0])
|
| 43 |
advices = ast.literal_eval((data[data['diseases']==str(disease)]["Advices"]).iloc[0])
|
| 44 |
return sympto,investigations,drugs,advices
|
| 45 |
+
#------------------------------------------------
|
| 46 |
+
api = HfApi()
|
| 47 |
+
|
| 48 |
+
# Replace with your Hugging Face Spaces username and repository name
|
| 49 |
+
username = "Add-Vishnu"
|
| 50 |
+
repo_name = "cdss_kb_generation"
|
| 51 |
+
|
| 52 |
+
# Replace with the CSV file name
|
| 53 |
+
filename = "demo1.csv"
|
| 54 |
|
| 55 |
+
# Load the repository
|
| 56 |
+
repo = HfFolder(repo_name, api=api, username=username)
|
| 57 |
+
#---------------------------------------------------------
|
| 58 |
def save_data(disease,symp_data,invest_data,drug_data,advice_data):
|
| 59 |
user = ""
|
| 60 |
for username, logged_in in logged_in_users.items():
|
| 61 |
if logged_in:
|
| 62 |
user = username
|
| 63 |
print("In save:",user)
|
| 64 |
+
# Read the existing content of the CSV file
|
| 65 |
+
file_path = repo.filename_to_path(filename)
|
| 66 |
+
existing_rows = []
|
| 67 |
+
with open(file_path, "r") as csv_file:
|
| 68 |
+
print("Read the data")
|
| 69 |
+
csv_reader = csv.reader(csv_file)
|
| 70 |
+
for row in csv_reader:
|
| 71 |
+
existing_rows.append(row)
|
| 72 |
try:
|
| 73 |
print("In try")
|
| 74 |
with open("./demo1.csv", mode="w", newline="") as csvfile:
|