PYTHON   87
for line in readlines
Guest on 16th March 2023 12:17:19 AM


  1. f = open('iii.log', 'r')
  2.  
  3. q = {}
  4. for line in f.readlines():
  5.     parts = line.split(" ")
  6.     if (parts[4] == "(2031)"):
  7.         # threadid, barcode, time
  8.         # print parts[3], parts[10], parts[1]
  9.  
  10.         q[(parts[3], parts[10])] = parts[1]
  11.  
  12.     if (parts[4] == "(2032)"):
  13.         #print q[(parts[3], parts[10])], parts[1]
  14.  
  15.         then = q[(parts[3], parts[10])]
  16.         now = parts[1]
  17.  
  18.         then = then.replace(":", ".")
  19.         now = now.replace(":", ".")
  20.  
  21.         then = then.split(".")
  22.         now = now.split(".")
  23.  
  24.         then = (int(then[0]) * 3600) + (int(then[1]) * 60) + int(then[2])
  25.         now = (int(now[0]) * 3600) + (int(now[1]) * 60) + int(now[2])
  26.  
  27.         print now - then
  28.  
  29.         del q[(parts[3], parts[10])]
  30.  
  31.     #print "interleaved: %d" % (len(q))

Raw Paste

Login or Register to edit or fork this paste. It's free.