qwerty45-uiop commited on
Commit
27d5ede
·
verified ·
1 Parent(s): 9ee06e8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +22 -29
src/streamlit_app.py CHANGED
@@ -25,40 +25,33 @@ st.set_page_config(
25
  @st.cache_data
26
  def load_data():
27
  try:
28
- # Load BITS data
29
- bits_df = pd.read_excel("BITS_INTERNS.xlsx", sheet_name="Form Responses 1")
30
- bits_df.columns = bits_df.columns.str.strip()
31
-
32
- # Load ICFAI data
33
- icfai_df = pd.read_excel("Summer of AI - ICFAI (Responses) (3).xlsx")
34
- icfai_df.columns = icfai_df.columns.str.strip()
35
-
36
- # Rename ICFAI columns to match BITS format
37
- icfai_df = icfai_df.rename(columns={
38
- "Name": "Full Name",
39
- "Laptop RAM (e.g. 8GB)": "Laptop RAM",
40
- "Mobile RAM (e.g. 6GB)": "Mobile RAM",
 
 
 
 
41
  "Laptop OS": "Laptop Operating System",
42
  "Mobile OS": "Mobile Operating System"
43
- })
44
 
45
- # Align columns in both datasets
46
- common_columns = ["Full Name", "Laptop RAM", "Mobile RAM", "Laptop Operating System", "Mobile Operating System"]
47
- bits_df = bits_df[common_columns]
48
- icfai_df = icfai_df[common_columns]
49
-
50
- # Add source tags
51
- bits_df["Institute"] = "BITS"
52
- icfai_df["Institute"] = "ICFAI"
53
-
54
- # Combine datasets
55
- combined_df = pd.concat([bits_df, icfai_df], ignore_index=True)
56
-
57
- st.info("✅ Loaded and merged data from BITS and ICFAI.")
58
- return combined_df, None
59
 
60
  except Exception as e:
61
- return None, f"Error loading or merging data: {str(e)}"
62
 
63
 
64
  # Enhanced RAM extraction with better parsing
 
25
  @st.cache_data
26
  def load_data():
27
  try:
28
+ # Load BITS file
29
+ df_bits = pd.read_excel("/mnt/data/BITS_INTERNS.xlsx", sheet_name="Form Responses 1")
30
+ df_bits["Source"] = "BITS"
31
+
32
+ # Load ICFAI file
33
+ df_icfai = pd.read_excel("/mnt/data/Summer of AI - ICFAI (Responses) (3).xlsx", sheet_name=0)
34
+ df_icfai["Source"] = "ICFAI"
35
+
36
+ # Align columns by renaming if needed (e.g., if column names differ)
37
+ df_bits.columns = df_bits.columns.str.strip()
38
+ df_icfai.columns = df_icfai.columns.str.strip()
39
+
40
+ # Optional: Rename columns in ICFAI to match BITS (only if necessary)
41
+ df_icfai.rename(columns={
42
+ "Your Full Name": "Full Name",
43
+ "Laptop RAM Capacity": "Laptop RAM",
44
+ "Mobile RAM Capacity": "Mobile RAM",
45
  "Laptop OS": "Laptop Operating System",
46
  "Mobile OS": "Mobile Operating System"
47
+ }, inplace=True)
48
 
49
+ # Combine both
50
+ df_combined = pd.concat([df_bits, df_icfai], ignore_index=True)
51
+ return df_combined, None
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  except Exception as e:
54
+ return None, f"Error loading Excel files: {str(e)}"
55
 
56
 
57
  # Enhanced RAM extraction with better parsing