3morrrrr commited on
Commit
167b29b
·
verified ·
1 Parent(s): 9374a4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -21
app.py CHANGED
@@ -107,32 +107,30 @@ def update_assignments(assignments_df, creators_df):
107
  except Exception as e:
108
  return f"Error updating assignments: {e}", None
109
 
110
- def generate_full_schedule(creators_file, overnight_file, day_file, prime_file):
111
  try:
112
- # Read uploaded files directly
113
- chatter_files = [
114
- pd.read_excel(overnight_file),
115
- pd.read_excel(day_file),
116
- pd.read_excel(prime_file),
117
- ]
118
- creators_data = pd.read_excel(creators_file)
119
-
120
- # Debugging: Log the columns of the files
121
- print("DEBUG: Creators File Columns:", creators_data.columns)
122
- for idx, chatter_df in enumerate(chatter_files):
123
- print(f"DEBUG: Chatter File {idx + 1} Columns:", chatter_df.columns)
124
 
125
- # Rename "Creator" to "Account" to match the expected column in the schedule function
126
- if "Creator" in creators_data.columns:
127
- creators_data.rename(columns={"Creator": "Account"}, inplace=True)
128
 
129
- # Validate data structure
130
- required_creator_columns = {"Account", "ActiveFans"}
131
- if not required_creator_columns.issubset(creators_data.columns):
132
- return f"Error: Creators file must contain the columns {required_creator_columns}."
133
 
134
- # Generate schedule
 
135
  full_schedule = generate_schedule(chatter_files, creators_data)
 
136
  return full_schedule
137
  except Exception as e:
138
  return f"Error generating schedule: {e}"
 
107
  except Exception as e:
108
  return f"Error updating assignments: {e}", None
109
 
110
+ def generate_full_schedule(creators_file_path, overnight_file_path, day_file_path, prime_file_path):
111
  try:
112
+ # Log file paths for debugging
113
+ print(f"DEBUG: Creators File Path: {creators_file_path}")
114
+ print(f"DEBUG: Overnight File Path: {overnight_file_path}")
115
+ print(f"DEBUG: Day File Path: {day_file_path}")
116
+ print(f"DEBUG: Prime File Path: {prime_file_path}")
117
+
118
+ # Read files
119
+ creators_data = pd.read_excel(creators_file_path)
120
+ overnight_data = pd.read_excel(overnight_file_path)
121
+ day_data = pd.read_excel(day_file_path)
122
+ prime_data = pd.read_excel(prime_file_path)
 
123
 
124
+ print("DEBUG: Creators File Columns:", creators_data.columns)
 
 
125
 
126
+ # Validate structure
127
+ if not {"Creator", "ActiveFans"}.issubset(creators_data.columns):
128
+ raise KeyError("The account data must contain 'Creator' and 'ActiveFans' columns.")
 
129
 
130
+ # Pass data to generate_schedule
131
+ chatter_files = [overnight_data, day_data, prime_data]
132
  full_schedule = generate_schedule(chatter_files, creators_data)
133
+
134
  return full_schedule
135
  except Exception as e:
136
  return f"Error generating schedule: {e}"