Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -125,14 +125,23 @@ def save_feedback_to_excel(name, email, feedback):
|
|
| 125 |
|
| 126 |
# Check if the file already exists
|
| 127 |
if os.path.exists(feedback_file):
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
def side():
|
| 137 |
with st.sidebar.form(key='feedback_form'):
|
| 138 |
|
|
|
|
| 125 |
|
| 126 |
# Check if the file already exists
|
| 127 |
if os.path.exists(feedback_file):
|
| 128 |
+
try:
|
| 129 |
+
# Load the existing file using the openpyxl engine
|
| 130 |
+
existing_df = pd.read_excel(feedback_file, engine='openpyxl')
|
| 131 |
+
df = pd.concat([existing_df, df], ignore_index=True)
|
| 132 |
+
except Exception as e:
|
| 133 |
+
st.error(f"Error reading existing feedback file: {e}")
|
| 134 |
+
return
|
| 135 |
+
else:
|
| 136 |
+
# If file doesn't exist, just proceed with the new DataFrame
|
| 137 |
+
st.success("Feedback file created and feedback saved!")
|
| 138 |
+
|
| 139 |
+
try:
|
| 140 |
+
# Save to Excel using the openpyxl engine
|
| 141 |
+
df.to_excel(feedback_file, index=False, engine='openpyxl')
|
| 142 |
+
st.success("Feedback saved successfully!")
|
| 143 |
+
except Exception as e:
|
| 144 |
+
st.error(f"Error saving feedback to Excel: {e}")
|
| 145 |
def side():
|
| 146 |
with st.sidebar.form(key='feedback_form'):
|
| 147 |
|