we are handling the dates without user input

This commit is contained in:
2022-04-14 14:29:35 +02:00
parent d6061d3145
commit 7ecc07780d

View File

@@ -21,9 +21,13 @@ FILE = FILE[0]
ext_date_from_filaname = FILE.split('_')[-1]
print(ext_date_from_filaname)
usrmonth = input("Month to be processed: ")
usrmonth = int(usrmonth)
# get month to be processed
head, mid, tail = ext_date_from_filaname.partition('.')
print(head)
usrmonth = head[-2:]
print(usrmonth)
dictionary = {}
@@ -64,9 +68,17 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
continue
my_string = row['Začátek fakturačního období']
#my_string = '2021-09-06'
print("start date: ",my_string)
monthfromfile = my_string.split(".", 3)
print(monthfromfile[1])
monthfromfile = monthfromfile[1]
try:
my_date = datetime.strptime(my_string, "%d.%m.%Y")
except:
@@ -78,8 +90,9 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
#print(my_date.month)
if usrmonth != my_date.month:
if usrmonth != monthfromfile:
print("skipping bad date")
continue #skip bad dates
@@ -193,7 +206,7 @@ with open('output_TMCZ_'+ext_date_from_filaname, 'w') as f:
f.close()
sys.exit()
with open('output_TMCZ_'+ext_date_from_filaname, "rb") as f:
webhook.add_file(file=f.read(), filename='output_TMCZ_'+ext_date_from_filaname)