Created
November 7, 2015 23:29
-
-
Save offbyone/d871116acf17f3cf44f5 to your computer and use it in GitHub Desktop.
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 python3 | |
import sys | |
import json | |
total = err = 0 | |
for line_no, line in enumerate(sys.stdin): | |
try: | |
d = eval(line.rstrip()) | |
except Exception as e: | |
sys.stderr.write("Line {} was malformed: {}\n".format(line_no, e)) | |
err += 1 | |
else: | |
json.dump(d, sys.stdout) | |
sys.stdout.write('\n') | |
finally: | |
total += 1 | |
sys.stderr.write("""\ | |
Total tweets: {} | |
Fixed tweets: {} | |
Unsalvageable: {} | |
Proportion: {:%} | |
""".format(total, total - err, err, err / total)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment