Skip to content

Instantly share code, notes, and snippets.

@r1ddl3m37h15
Last active June 4, 2020 01:34
Show Gist options
  • Save r1ddl3m37h15/e692c36bc19db107066cd9e66578551f to your computer and use it in GitHub Desktop.
Save r1ddl3m37h15/e692c36bc19db107066cd9e66578551f to your computer and use it in GitHub Desktop.
log parse count dates
import fileinput
from datetime import datetime
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter
x, y = [], []
for line in fileinput.input():
y.append(int(line.split()[0]))
x.append(datetime.fromisoformat(line.split()[1]))
fig, ax = plt.subplots()
ax.plot(x,y)
myFmt = DateFormatter("%d")
ax.xaxis.set_major_formatter(myFmt)
## Rotate date labels automatically
fig.autofmt_xdate()
plt.show()
#!/bin/bash
grep -o "[0-9]\{1,4\}-[0-9]\{1,2\}-[0-9]\{1,4\}" sample.log | sort | uniq -c | python3 ./date.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment