Python Forum
Need to add hours min and seconds
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to add hours min and seconds
#3
import os
too = r'C:/01/OUTCOME.txt'
with open(too) as fo:        
    sec = 0
    for line in fo:
        res = line.split(',')
        ontu=res[2].strip()
        sd,st=ontu.split('.')
        sdh,sdm,sds=sd.split(':')
        sec += int(sdh)*3600 + int(sdm)*60 + int(sds)
    print(str(datetime.timedelta(seconds=sec)))
Reply


Messages In This Thread
Need to add hours min and seconds - by tester_V - Jun-02-2020, 01:00 AM
RE: Need to add hours min and seconds - by frank0903 - Jun-02-2020, 03:27 AM
RE: Need to add hours min and seconds - by tester_V - Jun-02-2020, 04:36 AM
RE: Need to add hours min and seconds - by tester_V - Jun-02-2020, 05:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with module time and leap seconds Pedroski55 3 1,295 Oct-07-2022, 11:27 PM
Last Post: Pedroski55
  MatplotibTicks every 24 hours TamP 4 1,219 Oct-04-2022, 04:08 PM
Last Post: deanhystad
  Hello all! need help. calculating OT hours. no1up 5 1,571 Jul-30-2022, 10:00 PM
Last Post: rob101
  Store variable data and display sum after 60 seconds the_dude 11 3,541 Dec-16-2021, 07:07 PM
Last Post: deanhystad
  Py script that triggers ever 3 hours, but only between 9:15 am to 3:30 pm, Mon to Fri Pymod 2 1,870 Jun-30-2021, 05:14 PM
Last Post: Larz60+
  How to get utcnow + 2 hours? korenron 2 2,603 Mar-01-2021, 03:22 PM
Last Post: korenron
  How to calculate time difference between each row of dataframe in seconds Mekala 1 2,635 Jul-16-2020, 12:57 PM
Last Post: Larz60+
  Can't substract seconds from time Raj_Kumar 1 1,829 Apr-15-2020, 02:47 AM
Last Post: bowlofred
  How to calculate time in seconds rajeshE 1 2,140 Feb-15-2020, 11:07 PM
Last Post: Larz60+
  how to stop and start a script for 30 seconds laspaul 9 7,801 Jan-16-2020, 02:13 PM
Last Post: laspaul

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020