Advertisement
gauravssnl

MinMaxOperationTimeFromLogFile.py

Mar 11th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # Find min and max time of an operation from a log file
  2. __author__ = 'gauravssnl'
  3.  
  4. file ='c:\\logfile.txt'
  5. f = open(file)
  6. operation_time_dict =  { }
  7. for data in f :
  8.     data = data.strip( )
  9.     data_list = data.split( ',' )
  10.     key = data_list[0]
  11.     val = data_list[1]
  12.     if operation_time_dict.has_key( key ) is False :
  13.         operation_time_dict[ key] = [ val ]
  14.     else :
  15.         (operation_time_dict[ key ] ).append(val)
  16.  
  17. operation_list = operation_time_dict.keys()
  18. operation_list.sort()
  19.      
  20. for key in operation_list :
  21.     print('%s , %s , %s' %( key , min( operation_time_dict[ key ]) , max( operation_time_dict[ key ] ) ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement