qwerty45-uiop commited on
Commit
b062bc1
·
verified ·
1 Parent(s): f757005

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +37 -31
src/streamlit_app.py CHANGED
@@ -22,38 +22,44 @@ st.set_page_config(
22
  )
23
 
24
  # Enhanced data loading with error handling - FIXED FILE PATH
25
- @st.cache_data
 
26
  def load_data():
27
- def try_read_excel(path: str) -> Optional[pd.DataFrame]:
28
- try:
29
- df = pd.read_excel(path, sheet_name=0)
30
- df.columns = df.columns.str.strip()
31
- return df
32
- except Exception:
33
- return None
34
-
35
- possible_files = [
36
- "BITS_INTERNS.xlsx",
37
- "src/BITS_INTERNS.xlsx",
38
- "./BITS_INTERNS.xlsx",
39
- "Summer of AI - ICFAI (Responses) (3).xlsx",
40
- "src/Summer of AI - ICFAI (Responses) (3).xlsx",
41
- "./Summer of AI - ICFAI (Responses) (3).xlsx"
42
- ]
43
-
44
- dfs = []
45
- for file in possible_files:
46
- df = try_read_excel(file)
47
- if df is not None:
48
- st.info(f"✅ Loaded data from: {file}")
49
- dfs.append(df)
50
-
51
- if not dfs:
52
- return None, " No valid Excel files found. Please upload at least one file."
53
-
54
- # Merge all valid DataFrames
55
- combined_df = pd.concat(dfs, ignore_index=True)
56
- return combined_df, None
 
 
 
 
 
57
 
58
 
59
  # Enhanced RAM extraction with better parsing
 
22
  )
23
 
24
  # Enhanced data loading with error handling - FIXED FILE PATH
25
+
26
+ @st.cache_data
27
  def load_data():
28
+ try:
29
+ # Load BITS data
30
+ bits_df = pd.read_excel("BITS_INTERNS.xlsx", sheet_name="Form Responses 1")
31
+ bits_df.columns = bits_df.columns.str.strip()
32
+
33
+ # Load ICFAI data
34
+ icfai_df = pd.read_excel("Summer of AI - ICFAI (Responses) (3).xlsx")
35
+ icfai_df.columns = icfai_df.columns.str.strip()
36
+
37
+ # Rename ICFAI columns to match BITS format
38
+ icfai_df = icfai_df.rename(columns={
39
+ "Name": "Full Name",
40
+ "Laptop RAM (e.g. 8GB)": "Laptop RAM",
41
+ "Mobile RAM (e.g. 6GB)": "Mobile RAM",
42
+ "Laptop OS": "Laptop Operating System",
43
+ "Mobile OS": "Mobile Operating System"
44
+ })
45
+
46
+ # Align columns in both datasets
47
+ common_columns = ["Full Name", "Laptop RAM", "Mobile RAM", "Laptop Operating System", "Mobile Operating System"]
48
+ bits_df = bits_df[common_columns]
49
+ icfai_df = icfai_df[common_columns]
50
+
51
+ # Add source tags
52
+ bits_df["Institute"] = "BITS"
53
+ icfai_df["Institute"] = "ICFAI"
54
+
55
+ # Combine datasets
56
+ combined_df = pd.concat([bits_df, icfai_df], ignore_index=True)
57
+
58
+ st.info("✅ Loaded and merged data from BITS and ICFAI.")
59
+ return combined_df, None
60
+
61
+ except Exception as e:
62
+ return None, f"Error loading or merging data: {str(e)}"
63
 
64
 
65
  # Enhanced RAM extraction with better parsing