Hi, I was trying to flag timestamps that increment but 1,but cannot be more than 3 matches and not '0:00:00' or '0:00:01', lastly flag the highest out of 3 or 2 matches.
Any ideas on how solve this issue would be amazing
.
This is what I have so far:
This is the TS class:
Any ideas on how solve this issue would be amazing
. This is what I have so far:
This is the TS class:
from datetime import timedelta
class TS():
'''This class + and - timestamps hr:min:sec'''
def __init__(self, input_TS):
self.input_TS = str(input_TS)
if input_TS == None:
input_TS = "0:00:00"
hours, minute, seconds = input_TS.split(":")
self.hours = int(hours)
self.minute = int(minute)
self.seconds = int(seconds)
self.TS = timedelta(hours=self.hours,
minutes=self.minute,
seconds=self.seconds)
def __add__(self, other):
return str(self.TS + other.TS)
def __sub__(self, other):
return str(self.TS - other.TS)
def __str__(self):
return self.input_TS
def __repr__(self):
return repr(self.TS)
if __name__ == '__main__':
print("TS.py File")Main Script:from TS import TS
raw_TS_list = ['0:00:00', '0:00:01', '0:02:25', '0:02:26', '0:02:27',
'0:02:28', '0:02:29', '0:02:30', '0:02:31', '0:11:39',
'0:11:40', '0:22:10', '0:22:11', '0:35:06', '0:35:07',
'0:35:08', '0:43:12', '0:43:18', '0:43:20', '0:43:22',
'0:43:23', '0:43:26', '0:45:28', '0:45:29', '0:45:57',
'0:45:58']
def remove_duplicates(input_list):
print('Removing Duplicates...')
cleaned_list = list(set(input_list))
return sorted(cleaned_list)
def ts_parsing(input_list):
not_a_TS_list = {'0:00:00', '0:00:01'}
ts_old = None
for ts in remove_duplicates(input_list):
if ts not in not_a_TS_list:
if TS(ts) - TS(ts_old) == "0:00:01":
print(f"most likely: {repr(ts)}")
else:
print(f"{repr(ts_old)}")
ts_old = ts
print(repr(ts))This is the output:Output:'0:00:00'
'0:00:01'
'0:00:01'
'0:02:25'
most likely: '0:02:26'
'0:02:26'
most likely: '0:02:27'
'0:02:27'
most likely: '0:02:28'
'0:02:28'
most likely: '0:02:29'
'0:02:29'
most likely: '0:02:30'
'0:02:30'
most likely: '0:02:31'
'0:02:31'
'0:02:31'
'0:11:39'
most likely: '0:11:40'
'0:11:40'
'0:11:40'
'0:22:10'
most likely: '0:22:11'
'0:22:11'
'0:22:11'
'0:35:06'
most likely: '0:35:07'
'0:35:07'
most likely: '0:35:08'
'0:35:08'
'0:35:08'
'0:43:12'
'0:43:12'
'0:43:18'
'0:43:18'
'0:43:20'
'0:43:20'
'0:43:22'
most likely: '0:43:23'
'0:43:23'
'0:43:23'
'0:43:26'
'0:43:26'
'0:45:28'
most likely: '0:45:29'
'0:45:29'
'0:45:29'
'0:45:57'
most likely: '0:45:58'
'0:45:58'This what it should look like,,Output:Removing Duplicates...
'0:02:25'
'0:02:26'
'0:02:27'
'0:02:28'
'0:02:29'
'0:02:30'
'0:02:31'
'0:11:39'
'0:11:40'
'0:22:10'
most likely: '0:22:11'
'0:35:06'
'0:35:07'
most likely: '0:35:08'
'0:43:12'
'0:43:18'
'0:43:20'
'0:43:22'
most likely: '0:43:23'
'0:43:26'
'0:45:28'
most likely: '0:45:29'
'0:45:57'
most likely: '0:45:58'
