Created
May 6, 2019 02:44
-
-
Save rickheil/9cd2c700823a49415060e8d3ff4ddbce 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/python | |
import csv | |
import re | |
input_file = csv.DictReader(open("GroupsReport-cleaned.csv")) | |
for row in input_file: | |
clean_members = "" | |
# appriver gives us PSV with other garbage so we need to clean it up | |
dirty_members = row["Members"].split("|") | |
# remove any empty entries | |
while("" in dirty_members): | |
dirty_members.remove("") | |
# extract emails to get rid of the names | |
for member in dirty_members: | |
email = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", member) | |
clean_members = clean_members + "," + email[0] | |
print "New-DistributionGroup -Name %s -PrimarySmtpAddress %s@beamland.com -Members %s" % (row["Name"], row["Name"], clean_members[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment