File size: 1,600 Bytes
67f9cb6 6b19742 67f9cb6 d335e10 67f9cb6 754575e 67f9cb6 5847a79 67f9cb6 5847a79 67f9cb6 5847a79 0b4e8d6 1ddbfdc 5847a79 1ddbfdc 5847a79 67f9cb6 5847a79 d233f85 5847a79 d335e10 5847a79 9ac4415 d233f85 d335e10 5847a79 afb4f81 5847a79 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
from datasets import load_dataset
import streamlit as st
import pandas as pd
# Load your dataset (replace 'your-dataset' with the actual dataset name)
csv_url = 'https://huggingface.co/datasets/NENS/wim_data/resolve/main/input_employees/boran.csv'
#df = pd.read_csv('esther.csv')
#st.write(df)
#df.loc[df['week'] == 42, 'druk'] = 'heel druk'
#hoi= fs.ls("datasets/NENS/wim_data/input_employees/", detail=False)
#st.write(hoi)
#button = st.button('do it')
#if button:
#st.write(df)
#with fs.open("datasets/NENS/wim_data/input_employees/esther.csv", "w") as f:
# f.write("text,label")
# f.write("Fantastic movie!,good")
#https://huggingface.co/datasets/NENS/wim_data/resolve/main/input_employees/esther.csv
#df.to_csv("hf://spaces/NENS/test/test.csv")
#print('het werkt!')
from huggingface_hub import HfFileSystem
import pandas as pd
# Initialize HfFileSystem
fs = HfFileSystem()
# Define the path to your file in the Hugging Face Space
remote_csv_path = "esther.csv" # Path to the file in your repo
# Step 1: Read the CSV file from your Hugging Face Space
with fs.open(remote_csv_path, 'rb') as f:
df = pd.read_csv(f)
print("Original DataFrame:")
print(df)
# Step 2: Make some changes to the DataFrame
df.loc[df['week'] == 42, 'druk'] = 'heel druk'
print("Modified DataFrame:")
print(df)
button = st.button('do it')
if button:
# Step 3: Save the modified DataFrame back to a CSV file
with fs.open(remote_csv_path, 'wb') as f:
df.to_csv(f, index=False)
print(f"Saved changes back to {remote_csv_path}") |