Python - How to get a column 'duration' with start and end time column in csv? -


i have problem in manipulating csv file. in csv file, there column 'start time' , 'complete time' , want column 'duration' using it. when tried duration = row[2] - row[1], showed me error message

'unsupported operand type(s) -: 'str' , 'str'.

since data obtained csv file of str type, can not operation:

duration = row[2] - row[1] 

i advice first convert row[2] , row[1] content, , operation.

import time complete_time = time.strptime(row[2]) start_time = time.strptime(row[1]) duration = complete_time - start_time 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -