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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
#1. Entferne non SAP/AEB Services #2. Lösche Übersicht Seite #3. Speichern als xls #4. Konvertieren xls to xlsx #5. Speichern als \\SAP\SD import openpyxl, win32com.client, calendar, pandas as pd, datetime as dt from datetime import datetime from datetime import date xlapp = win32com.client.DispatchEx("Excel.Application") print('Aktualisierung xlsx...') wbr = xlapp.Workbooks.Open('C:\Documents\Statistik Loader.xlsx') wbr.RefreshAll() xlapp.CalculateUntilAsyncQueriesDone() wbr.Save() print('Aktualisierung ist fertig.') xlapp.Quit() print('Lesen die xlsx Datei...') df = pd.read_excel('Statistik Loader.xlsx', 'Quelldaten', index_col=None, na_values=['NA']) df = df.drop(df[(df['State'] == 'closed')].index) df = df.drop(df[(df['Queue'] != '[1] Second Level::SAP') & (df['Queue'] != '[2] Third Level::SAP')].index) print('Reinigung xlsx...') writer = pd.ExcelWriter('Statistik.xlsx') df.to_excel(writer, 'Quelldaten', index=False) writer.save() print('Reinigung ist fertig.') Woerterbuch = { 'SD-EU': 0, 'JIS': 0, 'IAU240': 0, 'JAVA-Entwicklung': 0, 'Preisfindung': 0, 'LO-Logistik': 0, 'EDIFACT-Mapping': 0, 'IDocs': 0, 'EDI': 0, 'ABAP': 0, 'SAP-Basis': 0, 'Vertrieb': 0 } Dienste = { '[T000] SAP::JIT': 0 } for Wort in Woerterbuch: Wort = '[T000] SAP::' + Wort Dienste[Wort] = 0 class switch(object): value = None def __new__(class_, value): class_.value = value return True def case(*args): return any((arg == switch.value for arg in args)) wb = openpyxl.load_workbook('Statistik.xlsx') ws = wb['Quelldaten'] print('Kalkulation...') for cell in ws['I']: if str(cell.value) in Dienste: Dienste [str(cell.value)] += 1 ws = wb.create_sheet('T000') i = 0 for dienstName in Dienste: i += 1 ws.cell(row=i, column=1).value = dienstName ws.cell(row=i, column=2).value = Dienste[dienstName] currentdate = datetime.today().strftime('%d.%m.%Y') wb.save('\\\\java.sap.sd\DFS-Abteilungen$\SAP\SD\\' + currentdate + '.xlsx') print('File \\\\java.sap.sd\DFS-Abteilungen$\SAP\SD\\' + currentdate + '.xlsx ist gespeichert.') d,m,y = currentdate.split('.') woche = dt.date(int(y),int(m),int(d)).strftime("%V") monat = calendar.month_name[int(m)] outlook = win32com.client.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = 'uchla@feedback' mail.Subject = 'Die Liste Woche #' + woche + ', ' + monat mail.HtmlBody = 'Hallo, die Datei S:\SAP\SD\\' + currentdate + '.xlsx ist fertig. \r\n Viele Grüße \r\n' mail.Display(True) |