Spaces:
Runtime error
Runtime error
File size: 1,228 Bytes
c352470 97b3ea8 c352470 e6dc665 c352470 97b3ea8 c352470 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import os
from huggingface_hub import Repository
import pandas as pd
DATASET_REPO_URL = "https://huggingface.co./datasets/mertbozkurt/school_data"
DATA_FILENAME = "untitled.csv"
DATA_FILE = os.path.join("data", DATA_FILENAME)
HF_TOKEN = "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"
def pull_read():
repo = Repository(
local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
)
with open(DATA_FILE) as csvfile:
df = pd.read_csv(csvfile)
df = pd.DataFrame(df)
return repo, df
def make_new_data(sinav_kodu,ogrenci_no,notu,yanlislar):
yeni_satir = {"sinav_kodu": sinav_kodu,
"ogrenci_no": ogrenci_no,
"notu": notu,
"yanlis_sorulari": yanlislar}
new_data = pd.DataFrame([yeni_satir])
return new_data
def update(new_data, ex_df):
updated_df = pd.concat([ex_df, new_data])
return updated_df
def save_and_push(dataFrame,repo,fileName):
dataFrame.to_csv(fileName,index=False)
commit_url = repo.push_to_hub()
return commit_url
"""repo, repo_df = pull_read()
new_data = make_new_data(12,151718,56,80,"2,3,5")
updated_df = update(new_data,repo_df)
save_and_push(updated_df,repo)""" |