Update app.py
Browse files
app.py
CHANGED
@@ -84,21 +84,22 @@ edited_df = st.data_editor(
|
|
84 |
use_container_width=True,
|
85 |
num_rows="dynamic",
|
86 |
column_config=column_configs,
|
|
|
87 |
)
|
88 |
|
89 |
-
# Save only if
|
90 |
-
|
91 |
-
new_data = edited_df.fillna("").to_dict(orient="records")
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
100 |
|
101 |
-
st.toast("✅ Auto-saved changes!", icon="💾")
|
102 |
|
103 |
|
104 |
# --- Add New Entry ---
|
|
|
84 |
use_container_width=True,
|
85 |
num_rows="dynamic",
|
86 |
column_config=column_configs,
|
87 |
+
key="editable_table",
|
88 |
)
|
89 |
|
90 |
+
# Save only if changed
|
91 |
+
new_data = edited_df.fillna("").to_dict(orient="records")
|
|
|
92 |
|
93 |
+
if new_data != st.session_state.get("prev_data", []):
|
94 |
+
st.session_state.data = new_data
|
95 |
+
st.session_state.prev_data = new_data
|
96 |
|
97 |
+
with open(TMP_FILE, "w", encoding="utf-8") as f:
|
98 |
+
for item in new_data:
|
99 |
+
f.write(json.dumps(item, ensure_ascii=False) + "\n")
|
100 |
+
|
101 |
+
st.experimental_rerun()
|
102 |
|
|
|
103 |
|
104 |
|
105 |
# --- Add New Entry ---
|