I think this code will do what you want to do. In addition, you do not need to worry about night data and changing the date, as this converts it to a datetime object.
import datetime filtered_data=[] my_data=open(my_file,'r') for line in my_data: data_arr=line.split() dte=data_arr[0].split("/") r tme=data_arr[1].split(":") new_date=datetime.datetime((int(dte[2]),int(dte[0]),int(dte[1]), int(tme[0]),int(tme[1]),int(tme[2])) if filtered_data==[]: filtered_data.append(data_arr) else: if (new_date-old_date).seconds==6: filtered_data.append(data_arr) old_date=new_date
This will give you a list in which items are filtered according to your situation (every 6 seconds). Now, if you just want your resistance array to be distributed at intervals of 6 seconds, just use a simple loop or list comprehension, as shown below:
R_in_six_sec_interval=[R[2] for R in filtered_data]
source share