one of my friend helped me a bit. can you tune this ASAP.
import re
#from openpyxl import Workbook
list = []
checkTemp = range(16,40)
check_RSSI = range(30,80)
Temp_range = range(20,40)
count = 0
my_list=[]
def Tempvalidation(new_list):
#print (new_list)
temp = " "
node = []
flag_temp = False
flag_rssi = False
for data in new_list:
#print (data)
if(re.findall(r'^Received Temparature', data)):
if(re.findall(r'Node(.*?)value', data)):
node = re.findall(r'Node(.*?)value', data)
if (int(float((data.split(" ")[-1]).rstrip()))) in checkTemp:
flag_temp = True
temp = float((data.split(" ")[-1]).rstrip())
else:
#print ("I have returend")
pass
elif(re.findall(r'^Received RSSI', data)):
#print(abs(int(data.split(" ")[-1])))
if (abs(int(data.split(" ")[-1])) in check_RSSI):
#print (data.split(" ")[-1])
flag_rssi = True
else:
pass
else:
pass
if (flag_rssi and flag_temp):
print ('pass: ', node, flag_temp)
else:
pass
with open('C:\\Users\purendhar\Downloads\gateway_testing.txt', 'r') as file:
for line in file:
if (re.findall(r'^Received Battery', line)):
list.append(line)
count =count + 1
elif re.findall(r'^Received Temparature', line):
list.append(line)
count = count + 1
elif re.findall(r'^Received RSSI', line):
list.append(line)
count = count + 1
else:
pass
if count == 3:
#print (list)
Tempvalidation(list)
count = 0
list=[]
else:
pass
#print (list)