Created
March 4, 2017 05:00
-
-
Save samthor/dc4a149ac1a9279a1be368245b6ce151 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 | |
"""Returns the number of members of a master group in other groups. | |
Accepts Google Groups member export CSVs. Usage: | |
./members.py < master.csv other.csv groups.csv | |
""" | |
import csv | |
import sys | |
def membersOf(r): | |
reader = csv.reader(r) | |
out = set() | |
for row in reader: | |
if '@' in row[0]: | |
out.add(row[0]) | |
return out | |
def membersOfFile(f): | |
with open(f) as r: | |
return membersOf(r) | |
others = [(x, membersOfFile(x)) for x in sys.argv[1:]] | |
master = membersOf(sys.stdin) | |
for name, s in others: | |
print("{} has {} members, {} are in master".format(name, len(s), len(s.intersection(master)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment