-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersuche 1111.py
205 lines (168 loc) · 7.51 KB
/
Versuche 1111.py
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
from openpyxl import load_workbook
import matplotlib.pyplot as plt
import wx
global istodersoll
istodersoll = 0
global istodersoll_text
istodersoll_text = ""
class AuswahlBox(wx.Frame):
def __init__(self, parent, title):
super(AuswahlBox, self).__init__(parent, title=title, size=(250, 200))
panel = wx.Panel(self)
box = wx.BoxSizer(wx.VERTICAL)
auswahl = ["Auswahl treffen", "IST", "SOLL"]
self.label = wx.StaticText(panel, label="IST oder SOLL?", style=wx.ALIGN_CENTER)
box.Add(self.label, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 15)
self.combo = wx.ComboBox(panel, choices=auswahl)
box.Add(self.combo, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 20)
self.combo.Bind(wx.EVT_COMBOBOX, self.bei_Auswahl)
self.button = wx.Button(panel, label="Okay", style=wx.ALIGN_CENTER_HORIZONTAL)
box.Add(self.button, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 20)
self.button.Bind(wx.EVT_BUTTON, self.bei_Click)
panel.SetSizer(box)
self.Center()
self.Show()
def bei_Auswahl(self, event):
global istodersoll
global istodersoll_text
if self.combo.GetValue() == "IST":
self.label.SetLabel("Es wurde " + self.combo.GetValue() + " ausgewählt")
istodersoll = 1
istodersoll_text = " (IST-Werte)"
elif self.combo.GetValue() == "SOLL":
self.label.SetLabel("Es wurde " + self.combo.GetValue() + " ausgewählt")
istodersoll = 2
istodersoll_text = " (SOLL-Werte)"
else:
self.label.SetLabel("Bitte IST oder SOLL auswählen")
istodersoll = 0
print("Bitte IST oder SOLL auswählen")
def bei_Click(self, event):
self.Close()
class Cell:
def __init__(self, row, column, value, year, sheet, istodersoll):
self.row = row
self.column = column
self.value = value
self.year = year
self.sheet = sheet
if istodersoll == 1:
self.istodersoll = "IST"
elif istodersoll == 2:
self.istodersoll = "SOLL"
def ausgabe(self):
print("Mappe: " + str(self.sheet))
print("Jahr: " + str(self.year))
print(str(self.istodersoll) + "-Wert")
print("Spalte: " +str(self.column))
print("Zeile: " + str(self.row))
print("Wert: " + str(self.value))
def gen_years():
for x in range(1954, 2003):
yield x
def getdata(wanted):
wb = load_workbook(filename, data_only=True)
global istodersoll
data = []
years = []
cells = []
g = gen_years()
for sheet in range(len(wb.sheetnames)):
if wb.sheetnames[sheet] == "1954-1963":
wb.active = sheet
for zeile in range(1, 100):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 20, 2):
inhalt = wb.active.cell(row=zeile + 1, column= istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value/1000, year, wb.sheetnames[sheet], istodersoll))
elif wb.sheetnames[sheet] == "1964-1966":
wb.active = sheet
for zeile in range(1, 150):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 4, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value/1000, year, wb.sheetnames[sheet], istodersoll))
for spalte in range(4, 6, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value, year, wb.sheetnames[sheet], istodersoll))
elif wb.sheetnames[sheet] == "1967":
wb.active = sheet
for zeile in range(1, 150):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 2, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value, year, wb.sheetnames[sheet], istodersoll))
elif wb.sheetnames[sheet] == "1968-1972":
wb.active = sheet
for zeile in range(1, 150):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 10, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value, year, wb.sheetnames[sheet], istodersoll))
elif wb.sheetnames[sheet] == "1973-1986":
wb.active = sheet
for zeile in range(1, 200):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 28, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value, year, wb.sheetnames[sheet], istodersoll))
elif wb.sheetnames[sheet] == "1987-1997":
wb.active = sheet
for zeile in range(1, 200):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 22, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value, year, wb.sheetnames[sheet], istodersoll))
elif wb.sheetnames[sheet] == "1998-2002":
wb.active = sheet
for zeile in range(1, 200):
cell = wb.active.cell(row=zeile + 1, column=1)
if cell.value == wanted:
for spalte in range(0, 10, 2):
inhalt = wb.active.cell(row=zeile + 1, column=istodersoll + spalte + 1)
data.append(inhalt.value)
year = next(g)
cells.append(Cell(zeile, spalte, inhalt.value, year, wb.sheetnames[sheet], istodersoll))
return cells
def plot_matplot(new_cells):
years = []
data = []
for cell in new_cells:
years.append(cell.year)
data.append(cell.value)
plt.plot(years, data, "m")
plt.title("Haushaltsplan" + istodersoll_text)
plt.ylabel("Einnahmen/Ausgaben")
plt.xlabel("Jahre")
plt.text(60, .025, "Hallo")
plt.show()
filename = "/Haushaltsbücher_MPG_Test.xlsx"
wanted = "Test"
app = wx.App()
AuswahlBox(None, 'Auswahlmenü')
app.MainLoop()
new_cells = getdata(wanted)
plot_matplot(new_cells)
for cell in new_cells:
cell.ausgabe()
break