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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -