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 -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -