Nov-20-2023, 10:32 AM
(Nov-20-2023, 09:25 AM)enkliy Wrote: So any help would be great. I have tried with pandas but that not possible...You should show what you have tried,can do it Pandas but also there has parse the string first.
To help first step which should be is to parse time out and make it a time format.
>>> import re >>> from datetime import datetime >>> >>> s = '<150>Nov 7 07:38:33 DrayTek: Local User (MAC=B0-8C-75-C0-FF-8F): 172.16.91.7:57422 -> 17.57.172.11:443 (TCP)' >>> r = re.search(r'\d{2}:\d{2}:\d{2}', s) >>> time_str = r.group() >>> time_str '07:38:33' >>> datetime.strptime(time_str, '%H:%M:%S') datetime.datetime(1900, 1, 1, 7, 38, 33)When have time format can use timedelta between times.