Files
buchhaltung/analyze_excel.py
T
2026-04-26 07:51:39 +02:00

44 lines
1.8 KiB
Python

import openpyxl
from datetime import datetime
file_path = 'Kopie von Kostenrechnung der Nächsten jahre (3).xlsx'
wb = openpyxl.load_workbook(file_path, data_only=True)
sheet = wb['Tilgung bei Gleichbleibenden Be']
# Alle Kredit-Header in Zeile 1
credits = []
print('=== ALLE KREDITE (Zeile 1 & 2) ===')
for col in range(1, 30):
h1 = sheet.cell(1, col).value
h2 = sheet.cell(2, col).value
if h1 is not None:
print(f'Spalte {col}: Header1="{h1}", Header2="{h2}"')
if 'Restschuld' in str(h2) or 'Rate' in str(h2) or h2 is None:
credits.append({'col': col, 'name': h1, 'type': h2})
print('\n=== April 2026 suchen ===')
target_date = datetime(2026, 4, 1)
april_row = None
for row in range(1, 200):
cell_val = sheet.cell(row, 1).value
if isinstance(cell_val, datetime):
if cell_val.year == 2026 and cell_val.month == 4:
print(f'April 2026 in Zeile {row}: {cell_val}')
april_row = row
break
elif cell_val and '2026-04' in str(cell_val):
print(f'April 2026 in Zeile {row}: {cell_val}')
april_row = row
break
print(f'\n=== Werte für April 2026 (Zeile {april_row}) ===')
print('KREDITE mit Restschuld/Raten:')
print(f'Spalte 2 (Targo Bank Restschuld): {sheet.cell(april_row, 2).value}')
print(f'Spalte 6 (Käpke Restschuld): {sheet.cell(april_row, 6).value}')
print(f'Spalte 9 (DSL Bank Restschuld): {sheet.cell(april_row, 9).value}')
print(f'Spalte 13 (PSD Nord Restschuld): {sheet.cell(april_row, 13).value}')
print(f'Spalte 20 (Zingelstr. 14 Restschuld): {sheet.cell(april_row, 20).value}')
print(f'Spalte 21 (Sparkasse RATE): {sheet.cell(april_row, 21).value}')
print(f'Spalte 22 (Sparkasse Zinsen): {sheet.cell(april_row, 22).value}')
print(f'Spalte 24 (Gesamt Restschuld): {sheet.cell(april_row, 24).value}')