akwel_performance / src /data_loader.py
ArkenB's picture
Create src/data_loader.py
2c0c586 verified
raw
history blame contribute delete
789 Bytes
# src/data_loader.py
import pandas as pd
def load_data(file_path: str) -> pd.DataFrame | None:
try:
if file_path.endswith('.csv'):
df = pd.read_csv(file_path)
elif file_path.endswith(('.xls', '.xlsx')):
df = pd.read_excel(file_path)
else:
print("Unsupported file format.")
return None
# Basic validation: Ensure 'Department' column exists.
# Subject-specific columns will be handled by the preprocessor.
if 'Department' not in df.columns:
print("Missing required column: 'Department'")
return None
print("Data loaded successfully (wide format).")
return df
except Exception as e:
print(f"Error loading data: {e}")
return None