-
Notifications
You must be signed in to change notification settings - Fork 0
/
excelUtils.py
51 lines (41 loc) · 1.64 KB
/
excelUtils.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
""""
Just a little tool to create a longer excel command, personal usage
command is like:
=SUMME('Januar 2019'!M35;'Februar 2019'!M35;'März 2019'!M35;'April 2019'!M35;'Mai 2019'!M35)
"""
def exitCheck(checker):
if checker in ["e", "exit"]:
exit()
def getCommand(startMonth, endMonth, startYear, endYear, Field, Command):
builder = ""
months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]
if startMonth not in months or endMonth not in months or endYear < 1 or startYear < 1:
return "Error"
builder += "=" + Command.upper() + "("
monthIndex = months.index(startMonth)
# count months in a year and startyear to endyear
while startYear != endYear or monthIndex != months.index(endMonth)+1:
builder += "\'" + months[monthIndex] + " " + str(startYear) + "\'!" + Field + ";"
monthIndex = monthIndex + 1
if monthIndex > 12:
startYear = startYear + 1
monthIndex = 0
builder = builder[:-1] # cut off last semikolon
builder += ")"
return builder
while True:
print("Welcome to ExcelUtils")
command = input("Enter command: ")
exitCheck(command)
field = input("Enter field: ")
exitCheck(field)
endYear = int(input("Enter EndYear: "))
exitCheck(endYear)
startYear = int(input("Enter StartYear: "))
exitCheck(startYear)
endMonth = input("Enter endMonth: ")
exitCheck(endMonth)
startMonth = input("Enter startMonth: ")
exitCheck(startMonth)
print("Your command is: ")
print(getCommand(startMonth, endMonth, startYear, endYear, field, command))