import datetime
import time
import ftplib
NewRsult = []
IdList = []
count = 1
while True:
print(f'monitoring:{count}')
today = datetime.datetime.today().timetuple()
if today.tm_mon >= 10:
day = str(today.tm_year) + '-' + str(today.tm_mon) + '-' + str(today.tm_mday)
else:
day = str(today.tm_year) + '-0' + str(today.tm_mon) + '-' + str(today.tm_mday)
path = 'D:\\MaruTEST\\Log' + '\\' + day + '\\Cell.csv'
if (today.tm_hour == 0 and today.tm_min == 0):
NewRsult = []
IdList = []
else:
pass
with open(path,'r')as f:
TempRsult_str = f.read()
TempRsult_ls = TempRsult_str.split('\n')
Result_ls = list(set(NewRsult)^set(TempRsult_ls))
for each in Result_ls:
dfc = each.split(',')
try:
if (dfc[-2] == 'P_BLACK_SPOT' or dfc[-2] == 'P_SK'):
IdList.append(dfc[6])
else:
pass
except:
print("ok")
with open('monitor.txt','a+')as f:
f.write(f'{count,today.tm_hour,today.tm_min,len(IdList)}'+ '\n')
NewRsult = TempRsult_ls
time.sleep(60)
count += 1
|