-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (26 loc) · 1.1 KB
/
main.py
File metadata and controls
31 lines (26 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
def read_employee_list(file_path):
try:
data = pd.read_excel(file_path)
return data
except Exception as e:
print(f"Error reading file: {e}")
return None
def assign_secret_santa(employee_df):
shuffled_df = employee_df.sample(frac=1).reset_index(drop=True)
shuffled_df['Secret_Child_Name'] = shuffled_df['Employee_Name'].shift(-1, fill_value=shuffled_df['Employee_Name'].iloc[0])
shuffled_df['Secret_Child_EmailID'] = shuffled_df['Employee_EmailID'].shift(-1, fill_value=shuffled_df['Employee_EmailID'].iloc[0])
return shuffled_df
def save_to_csv(output_df, output_file):
try:
output_df.to_csv(output_file, index=False)
print(f"Output saved successfully to {output_file}")
except Exception as e:
print(f"Error saving file: {e}")
if __name__ == "__main__":
input_file = "Employee-List.xlsx"
output_file = "Secret_Santa_Output.csv"
employee_df = read_employee_list(input_file)
if employee_df is not None:
result_df = assign_secret_santa(employee_df)
save_to_csv(result_df, output_file)