Skip to content

Instantly share code, notes, and snippets.

@rickheil
Created May 6, 2019 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickheil/9cd2c700823a49415060e8d3ff4ddbce to your computer and use it in GitHub Desktop.
Save rickheil/9cd2c700823a49415060e8d3ff4ddbce to your computer and use it in GitHub Desktop.
#!/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