Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 16th, 2013  |  syntax: Python  |  size: 0.54 KB  |  views: 106  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import datetime
  2.  
  3.  
  4. data = """01:35:01 0.90 0.99 0.90
  5. 01:40:01 0.53 0.78 0.85
  6. 01:45:01 0.42 0.67 0.81
  7. 08:20:01 0.58 0.95 0.93
  8. 08:25:01 0.74 0.65 0.79
  9. 08:30:01 0.40 0.50 0.69"""
  10.  
  11. gap_delta = datetime.timedelta(hours=1)
  12.  
  13. prev_time = datetime.datetime.strptime(data[:8], "%H:%M:%S")
  14. for line in data.splitlines():
  15.    
  16.     time_string = line[:8]
  17.     next_time = datetime.datetime.strptime(time_string, "%H:%M:%S")
  18.    
  19.     if (next_time - prev_time) > gap_delta:
  20.         print "gap"
  21.     print time_string
  22.     prev_time = next_time
clone this paste RAW Paste Data