Skip to content

Instantly share code, notes, and snippets.

@lukebigum
Created February 5, 2016 13:53
Show Gist options
  • Save lukebigum/051be7eadfa9984f99ae to your computer and use it in GitHub Desktop.
Save lukebigum/051be7eadfa9984f99ae to your computer and use it in GitHub Desktop.
time difference between proceeding lines
from datetime import datetime, timedelta
import sys
last_t = None
min_delta = timedelta(seconds=1)
#2016-02-05T09:46:33Z
for line in sys.stdin:
t = datetime.strptime(line, "%Y-%m-%dT%H:%M:%SZ\n")
if last_t:
diff = t - last_t
if diff > min_delta:
print "%s - %s since last spike" % (t, diff)
last_t = t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment