Created
September 27, 2022 14:52
-
-
Save mi-skam/6a48f009a7706b311b768fe4d163b35a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shutil | |
import pandas as pd | |
source_file='SAM_Final_Rezert' | |
# 1. Öffnen des Excelfiles | |
stammdaten = pd.read_excel( | |
io=source_file + '.xlsx', | |
sheet_name='Stammdaten' | |
) | |
# 2. Die einzigartigen Werte der Spalte OE_Führungskraft | |
unique_managers = stammdaten['OE_Führungskraft'].unique() | |
# 3. Mit diesen Werten die gesamte Tabelle filtern | |
f_name = "output" | |
for manager in unique_managers: | |
filtered_list = stammdaten[stammdaten['OE_Führungskraft'].isin([manager])] | |
# 4. Diese gefilterten Werte in einzelne Excelfiles schreiben | |
# e.G. 'SAM_Final_Rezert_Experiment-11111_AAAAAAAA.xlsx' | |
f_name = source_file + '-' + manager + '.xlsx' | |
shutil.copy(source_file + '.xlsx', f_name) | |
with pd.ExcelWriter(f_name, mode='a', if_sheet_exists='replace') as writer: | |
filtered_list.to_excel(writer, sheet_name='Stammdaten', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment