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}")