Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -136,8 +136,8 @@ import pandas as pd
|
|
136 |
def main():
|
137 |
st.title("Intervention Program Analysis")
|
138 |
|
139 |
-
# File uploader
|
140 |
-
uploaded_file = st.file_uploader("Upload your Excel file", type=["xlsx"])
|
141 |
|
142 |
if uploaded_file is not None:
|
143 |
try:
|
@@ -145,7 +145,6 @@ def main():
|
|
145 |
df = pd.read_excel(uploaded_file)
|
146 |
|
147 |
# Step 2: Rename duplicate columns to make them unique
|
148 |
-
# Using built-in pandas functionality to handle duplicate column names
|
149 |
cols = pd.Series(df.columns)
|
150 |
for dup in cols[cols.duplicated()].unique():
|
151 |
cols[cols[cols == dup].index.values.tolist()] = [f"{dup}_{i+1}" if i != 0 else dup for i in range(sum(cols == dup))]
|
@@ -205,9 +204,6 @@ def main():
|
|
205 |
except Exception as e:
|
206 |
st.error(f"Error reading the file: {str(e)}")
|
207 |
|
208 |
-
if __name__ == "__main__":
|
209 |
-
main()
|
210 |
-
|
211 |
def replace_student_names_with_initials(df):
|
212 |
"""Replace student names in column headers with initials."""
|
213 |
updated_columns = []
|
|
|
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:
|
143 |
try:
|
|
|
145 |
df = pd.read_excel(uploaded_file)
|
146 |
|
147 |
# Step 2: Rename duplicate columns to make them unique
|
|
|
148 |
cols = pd.Series(df.columns)
|
149 |
for dup in cols[cols.duplicated()].unique():
|
150 |
cols[cols[cols == dup].index.values.tolist()] = [f"{dup}_{i+1}" if i != 0 else dup for i in range(sum(cols == dup))]
|
|
|
204 |
except Exception as e:
|
205 |
st.error(f"Error reading the file: {str(e)}")
|
206 |
|
|
|
|
|
|
|
207 |
def replace_student_names_with_initials(df):
|
208 |
"""Replace student names in column headers with initials."""
|
209 |
updated_columns = []
|