Created
March 17, 2010 22:48
-
-
Save ekohl/335825 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 python | |
import csv | |
import sys | |
import random | |
# For each argument to the program | |
for arg in sys.argv[1:]: | |
# Store all the data | |
rows = list(csv.DictReader(open(arg))) | |
trackers = list(set(row['Tracker'] for row in rows)) | |
# Pick a random tracker | |
tracker = trackers[random.randint(0, len(trackers)-1)] | |
# Print the data | |
for row in ( row for row in rows if row['Tracker'] == tracker ): | |
# The following 2 lines are equal | |
#print "[%s] %s: %s" % (row['Tracker'], row['Author'], row['Subject']) | |
print "[%(Tracker)s] %(Author)s: %(Subject)s" % row |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment