Update app.py
Browse files
app.py
CHANGED
@@ -2,33 +2,64 @@ from datasets import load_dataset
|
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
|
5 |
-
from huggingface_hub import HfFileSystem
|
6 |
-
fs = HfFileSystem()
|
7 |
|
8 |
# Load your dataset (replace 'your-dataset' with the actual dataset name)
|
9 |
csv_url = 'https://huggingface.co/datasets/NENS/wim_data/resolve/main/input_employees/boran.csv'
|
10 |
|
11 |
-
df = pd.read_csv('esther.csv')
|
12 |
|
13 |
-
st.write(df)
|
14 |
|
15 |
-
df.loc[df['week'] == 42, 'druk'] = 'heel druk'
|
16 |
|
17 |
|
18 |
-
hoi= fs.ls("datasets/NENS/wim_data/input_employees/", detail=False)
|
19 |
-
st.write(hoi)
|
20 |
|
21 |
-
button = st.button('do it')
|
22 |
|
23 |
-
if button:
|
24 |
|
25 |
-
st.write(df)
|
26 |
|
27 |
-
with fs.open("datasets/NENS/wim_data/input_employees/esther.csv", "w") as f:
|
28 |
-
|
29 |
-
|
30 |
|
31 |
#https://huggingface.co/datasets/NENS/wim_data/resolve/main/input_employees/esther.csv
|
32 |
|
33 |
#df.to_csv("hf://spaces/NENS/test/test.csv")
|
34 |
-
print('het werkt!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
|
|
|
|
|
5 |
|
6 |
# Load your dataset (replace 'your-dataset' with the actual dataset name)
|
7 |
csv_url = 'https://huggingface.co/datasets/NENS/wim_data/resolve/main/input_employees/boran.csv'
|
8 |
|
9 |
+
#df = pd.read_csv('esther.csv')
|
10 |
|
11 |
+
#st.write(df)
|
12 |
|
13 |
+
#df.loc[df['week'] == 42, 'druk'] = 'heel druk'
|
14 |
|
15 |
|
16 |
+
#hoi= fs.ls("datasets/NENS/wim_data/input_employees/", detail=False)
|
17 |
+
#st.write(hoi)
|
18 |
|
19 |
+
#button = st.button('do it')
|
20 |
|
21 |
+
#if button:
|
22 |
|
23 |
+
#st.write(df)
|
24 |
|
25 |
+
#with fs.open("datasets/NENS/wim_data/input_employees/esther.csv", "w") as f:
|
26 |
+
# f.write("text,label")
|
27 |
+
# f.write("Fantastic movie!,good")
|
28 |
|
29 |
#https://huggingface.co/datasets/NENS/wim_data/resolve/main/input_employees/esther.csv
|
30 |
|
31 |
#df.to_csv("hf://spaces/NENS/test/test.csv")
|
32 |
+
#print('het werkt!')
|
33 |
+
|
34 |
+
|
35 |
+
from huggingface_hub import HfFileSystem
|
36 |
+
import pandas as pd
|
37 |
+
|
38 |
+
# Initialize HfFileSystem
|
39 |
+
fs = HfFileSystem()
|
40 |
+
|
41 |
+
# Define the path to your file in the Hugging Face Space
|
42 |
+
remote_csv_path = "esther.csv" # Path to the file in your repo
|
43 |
+
|
44 |
+
# Step 1: Read the CSV file from your Hugging Face Space
|
45 |
+
with fs.open(remote_csv_path, 'rb') as f:
|
46 |
+
df = pd.read_csv(f)
|
47 |
+
|
48 |
+
print("Original DataFrame:")
|
49 |
+
print(df)
|
50 |
+
|
51 |
+
# Step 2: Make some changes to the DataFrame
|
52 |
+
df.loc[df['week'] == 42, 'druk'] = 'heel druk'
|
53 |
+
|
54 |
+
print("Modified DataFrame:")
|
55 |
+
print(df)
|
56 |
+
|
57 |
+
button = st.button('do it')
|
58 |
+
|
59 |
+
if button:
|
60 |
+
|
61 |
+
# Step 3: Save the modified DataFrame back to a CSV file
|
62 |
+
with fs.open(remote_csv_path, 'wb') as f:
|
63 |
+
df.to_csv(f, index=False)
|
64 |
+
|
65 |
+
print(f"Saved changes back to {remote_csv_path}")
|