Created
March 14, 2018 10:30
-
-
Save mbreese/00048f920718c53ce4ff5975f9c81a9d to your computer and use it in GitHub Desktop.
Sampling program to read write every X lines to stderr, otherwise, just read from stdin and write to stdout (useful for monitoring stream progress)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import datetime | |
rate = 100000 | |
if len(sys.argv) > 1: | |
rate = int(sys.argv[1]) | |
i = 0 | |
for line in sys.stdin: | |
i += 1 | |
if i > rate: | |
sys.stderr.write('\n%s\n' % datetime.datetime.now()) | |
sys.stderr.write(line) | |
i = 0 | |
sys.stdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment