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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -