Update app.py
Browse files
app.py
CHANGED
|
@@ -141,14 +141,12 @@ def main():
|
|
| 141 |
|
| 142 |
if uploaded_file is not None:
|
| 143 |
try:
|
| 144 |
-
# Step 1: Read the Excel file into a DataFrame
|
| 145 |
-
df = pd.read_excel(uploaded_file)
|
| 146 |
-
|
| 147 |
-
# Step 2: Rename duplicate columns to make them
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
cols[cols[cols == dup].index.values.tolist()] = [f"{dup}_{i+1}" if i != 0 else dup for i in range(sum(cols == dup))]
|
| 151 |
-
df.columns = cols
|
| 152 |
|
| 153 |
# Step 3: Replace student names with initials
|
| 154 |
df = replace_student_names_with_initials(df)
|
|
|
|
| 141 |
|
| 142 |
if uploaded_file is not None:
|
| 143 |
try:
|
| 144 |
+
# Step 1: Read the Excel file into a DataFrame and automatically rename duplicate columns
|
| 145 |
+
df = pd.read_excel(uploaded_file, mangle_dupe_cols=True)
|
| 146 |
+
|
| 147 |
+
# Step 2: Rename duplicate columns to make them more readable if needed
|
| 148 |
+
# Columns will already be unique, e.g., "Student Attendance [J]", "Student Attendance [J].1"
|
| 149 |
+
df.columns = [col.replace(".1", "_2").replace(".2", "_3") for col in df.columns]
|
|
|
|
|
|
|
| 150 |
|
| 151 |
# Step 3: Replace student names with initials
|
| 152 |
df = replace_student_names_with_initials(df)
|