qwerty45-uiop commited on
Commit
e99c3ea
·
verified ·
1 Parent(s): c7b21ca

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +23 -26
src/streamlit_app.py CHANGED
@@ -25,33 +25,30 @@ st.set_page_config(
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
 
25
  @st.cache_data
26
  def load_data():
27
  try:
28
+ # Try multiple possible file locations
29
+ possible_paths = [
30
+ "Merged_Student_Data.csv", # Current directory
31
+ "src/Merged_Student_Data.csv", # src subdirectory
32
+ "./Merged_Student_Data.csv", # Explicit current directory
33
+ ]
34
+
35
+ df = None
36
+ for path in possible_paths:
37
+ try:
38
+ df = pd.read_excel(path, sheet_name="Form Responses 1")
39
+ st.info(f"✅ Successfully loaded data from: {path}")
40
+ break
41
+ except FileNotFoundError:
42
+ continue
43
+
44
+ if df is None:
45
+ return None, "Excel file 'Merged_Student_Data.csv' not found in any expected location. Please ensure the file is in the same directory as this script."
46
+
47
+ df.columns = df.columns.str.strip()
48
+ return df, None
49
+
 
 
 
50
  except Exception as e:
51
+ return None, f"Error loading data: {str(e)}"
52
 
53
 
54
  # Enhanced RAM extraction with better parsing