SR05 commited on
Commit
a990f92
·
verified ·
1 Parent(s): 4d25dce

Update loading_file.py

Browse files
Files changed (1) hide show
  1. loading_file.py +12 -6
loading_file.py CHANGED
@@ -48,12 +48,18 @@ def fetch_data():
48
  df.dropna(how="all", inplace=True)
49
  df.reset_index(drop=True, inplace=True)
50
 
51
- # Identify header row and reformat DataFrame
52
- for idx, row in df.iterrows():
53
- if "Application Number" in row.values:
54
- df.columns = ["Application Number", "Decision"]
55
- df = df.iloc[idx + 1:] # Skip the header row
56
- break
 
 
 
 
 
 
57
 
58
  df["Application Number"] = df["Application Number"].astype(str)
59
  return df
 
48
  df.dropna(how="all", inplace=True)
49
  df.reset_index(drop=True, inplace=True)
50
 
51
+ # Check columns and rename appropriately
52
+ print("Columns before renaming:", df.columns.tolist()) # For debugging purposes
53
+
54
+ # Attempt to rename columns only if there are sufficient columns
55
+ if len(df.columns) >= 2:
56
+ df.columns = ["Application Number", "Decision"]
57
+ else:
58
+ st.error("Insufficient data columns detected.")
59
+ return None
60
+
61
+ # Only keep relevant columns
62
+ df = df[["Application Number", "Decision"]]
63
 
64
  df["Application Number"] = df["Application Number"].astype(str)
65
  return df