Spaces:
Running
Running
Commit
·
62c4367
1
Parent(s):
d76808b
added
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ from utils import (
|
|
7 |
|
8 |
import streamlit as st
|
9 |
import json
|
10 |
-
import textwrap as tw
|
11 |
import pandas as pd
|
|
|
12 |
from streamlit_extras.stylable_container import stylable_container
|
13 |
|
14 |
@st.cache_data
|
@@ -32,12 +32,15 @@ def edit_df_data_change():
|
|
32 |
|
33 |
st.need_rerun = False
|
34 |
if "df" not in st.session_state:
|
|
|
35 |
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
|
|
36 |
st.need_rerun = True
|
37 |
else:
|
38 |
uploaded_file = st.session_state.df
|
39 |
-
if uploaded_file is not None:
|
40 |
-
|
|
|
41 |
if "df" not in st.session_state:
|
42 |
df = load_data(uploaded_file)
|
43 |
st.session_state.df_shape = df.shape
|
@@ -48,10 +51,18 @@ if uploaded_file is not None:
|
|
48 |
comments = [''] * len(df)
|
49 |
df.insert(0, 'Comment', comments)
|
50 |
st.session_state.default_row_index = 0
|
|
|
|
|
|
|
|
|
|
|
51 |
else:
|
52 |
df['Comment'] = df['Comment'].astype(str)
|
|
|
53 |
comments = [c if c != 'nan' else '' for c in df['Comment'].tolist()]
|
|
|
54 |
df['Comment'] = comments
|
|
|
55 |
first_nan = 0
|
56 |
for i, c in enumerate(comments):
|
57 |
if not c:
|
@@ -187,6 +198,9 @@ if uploaded_file is not None:
|
|
187 |
st.session_state.df.at[row_index, 'Comment'] = comment
|
188 |
st.session_state.df.at[row_index, 'relative_relevancy'] = updated_relative_relevancy
|
189 |
st.session_state.df.at[row_index, 'correct_response'] = select_most_relevant
|
|
|
|
|
|
|
190 |
df = st.session_state.df.drop('Select', axis=1)
|
191 |
df.to_csv('modified.csv', index=False)
|
192 |
st.rerun()
|
|
|
7 |
|
8 |
import streamlit as st
|
9 |
import json
|
|
|
10 |
import pandas as pd
|
11 |
+
from datetime import datetime
|
12 |
from streamlit_extras.stylable_container import stylable_container
|
13 |
|
14 |
@st.cache_data
|
|
|
32 |
|
33 |
st.need_rerun = False
|
34 |
if "df" not in st.session_state:
|
35 |
+
role_pick = st.selectbox("You are?", options=["Kyle", "Shadi", "Daniel", "Xin"], index=None, key='role_pick')
|
36 |
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
37 |
+
st.session_state.role = role_pick
|
38 |
st.need_rerun = True
|
39 |
else:
|
40 |
uploaded_file = st.session_state.df
|
41 |
+
if uploaded_file is not None and 'role' in st.session_state:
|
42 |
+
"You are modifying as :", st.session_state.role
|
43 |
+
with st.container():
|
44 |
if "df" not in st.session_state:
|
45 |
df = load_data(uploaded_file)
|
46 |
st.session_state.df_shape = df.shape
|
|
|
51 |
comments = [''] * len(df)
|
52 |
df.insert(0, 'Comment', comments)
|
53 |
st.session_state.default_row_index = 0
|
54 |
+
|
55 |
+
if "LastModified" not in df.columns:
|
56 |
+
modifies = [''] * len(df)
|
57 |
+
df.insert(0, 'LastModified', modifies)
|
58 |
+
|
59 |
else:
|
60 |
df['Comment'] = df['Comment'].astype(str)
|
61 |
+
df['LastModified'] = df['LastModified'].astype(str)
|
62 |
comments = [c if c != 'nan' else '' for c in df['Comment'].tolist()]
|
63 |
+
modifies = [c if c != 'nan' else '' for c in df['LastModified'].tolist()]
|
64 |
df['Comment'] = comments
|
65 |
+
df['LastModified'] = modifies
|
66 |
first_nan = 0
|
67 |
for i, c in enumerate(comments):
|
68 |
if not c:
|
|
|
198 |
st.session_state.df.at[row_index, 'Comment'] = comment
|
199 |
st.session_state.df.at[row_index, 'relative_relevancy'] = updated_relative_relevancy
|
200 |
st.session_state.df.at[row_index, 'correct_response'] = select_most_relevant
|
201 |
+
current_time = datetime.now()
|
202 |
+
current_time_str = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
203 |
+
st.session_state.df.at[row_index, 'LastModified'] = f"{st.session_state.role}@{current_time_str}"
|
204 |
df = st.session_state.df.drop('Select', axis=1)
|
205 |
df.to_csv('modified.csv', index=False)
|
206 |
st.rerun()
|