Update app.py
Browse files
app.py
CHANGED
@@ -136,7 +136,6 @@ import pandas as pd
|
|
136 |
def main():
|
137 |
st.title("Intervention Program Analysis")
|
138 |
|
139 |
-
# File uploader with a unique key to avoid duplication errors
|
140 |
uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"], key="unique_excel_uploader")
|
141 |
|
142 |
if uploaded_file is not None:
|
@@ -145,10 +144,21 @@ def main():
|
|
145 |
df = pd.read_excel(uploaded_file)
|
146 |
|
147 |
# Step 2: Manually handle duplicate columns
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
# Step 4: Display the uploaded data
|
154 |
st.subheader("Uploaded Data")
|
@@ -156,7 +166,7 @@ def main():
|
|
156 |
|
157 |
# Step 5: Ensure expected column is available
|
158 |
if INTERVENTION_COLUMN not in df.columns:
|
159 |
-
st.error(f"Expected column '{INTERVENTION_COLUMN}' not found.")
|
160 |
return
|
161 |
|
162 |
# Step 6: Clean up column names
|
|
|
136 |
def main():
|
137 |
st.title("Intervention Program Analysis")
|
138 |
|
|
|
139 |
uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"], key="unique_excel_uploader")
|
140 |
|
141 |
if uploaded_file is not None:
|
|
|
144 |
df = pd.read_excel(uploaded_file)
|
145 |
|
146 |
# Step 2: Manually handle duplicate columns
|
147 |
+
def make_unique(column_name, existing_columns):
|
148 |
+
counter = 1
|
149 |
+
new_name = column_name
|
150 |
+
while new_name in existing_columns:
|
151 |
+
new_name = f"{column_name}_{counter}"
|
152 |
+
counter += 1
|
153 |
+
return new_name
|
154 |
+
|
155 |
+
unique_columns = []
|
156 |
+
for col in df.columns:
|
157 |
+
unique_columns.append(make_unique(col, unique_columns))
|
158 |
+
df.columns = unique_columns
|
159 |
+
|
160 |
+
# Step 3: Replace student names with initials
|
161 |
+
df = replace_student_names_with_initials(df)
|
162 |
|
163 |
# Step 4: Display the uploaded data
|
164 |
st.subheader("Uploaded Data")
|
|
|
166 |
|
167 |
# Step 5: Ensure expected column is available
|
168 |
if INTERVENTION_COLUMN not in df.columns:
|
169 |
+
st.error(f"Expected column '{INTERVENTION_COLUMN}' not found.")
|
170 |
return
|
171 |
|
172 |
# Step 6: Clean up column names
|