we are handling the dates without user input
This commit is contained in:
@@ -21,9 +21,13 @@ FILE = FILE[0]
|
|||||||
ext_date_from_filaname = FILE.split('_')[-1]
|
ext_date_from_filaname = FILE.split('_')[-1]
|
||||||
print(ext_date_from_filaname)
|
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 = {}
|
dictionary = {}
|
||||||
|
|
||||||
@@ -64,9 +68,17 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
my_string = row['Začátek fakturačního období']
|
my_string = row['Začátek fakturačního období']
|
||||||
|
|
||||||
#my_string = '2021-09-06'
|
#my_string = '2021-09-06'
|
||||||
print("start date: ",my_string)
|
print("start date: ",my_string)
|
||||||
|
|
||||||
|
monthfromfile = my_string.split(".", 3)
|
||||||
|
print(monthfromfile[1])
|
||||||
|
monthfromfile = monthfromfile[1]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
my_date = datetime.strptime(my_string, "%d.%m.%Y")
|
my_date = datetime.strptime(my_string, "%d.%m.%Y")
|
||||||
except:
|
except:
|
||||||
@@ -78,8 +90,9 @@ with open(FILE, newline='', encoding="utf-8") as csvfile:
|
|||||||
#print(my_date.month)
|
#print(my_date.month)
|
||||||
|
|
||||||
|
|
||||||
if usrmonth != my_date.month:
|
if usrmonth != monthfromfile:
|
||||||
print("skipping bad date")
|
print("skipping bad date")
|
||||||
|
|
||||||
continue #skip bad dates
|
continue #skip bad dates
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +206,7 @@ with open('output_TMCZ_'+ext_date_from_filaname, 'w') as f:
|
|||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
with open('output_TMCZ_'+ext_date_from_filaname, "rb") as f:
|
with open('output_TMCZ_'+ext_date_from_filaname, "rb") as f:
|
||||||
webhook.add_file(file=f.read(), filename='output_TMCZ_'+ext_date_from_filaname)
|
webhook.add_file(file=f.read(), filename='output_TMCZ_'+ext_date_from_filaname)
|
||||||
|
|||||||
Reference in New Issue
Block a user