Created
May 24, 2018 09:56
-
-
Save lc-at/86f0541dd1bdcfae2152ed98956f1b2a to your computer and use it in GitHub Desktop.
Mailist Grouper
This file contains hidden or 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
# Mailist Grouper | |
import sys | |
print("""\ | |
+-----------------------------+ | |
| Mailist Grouper | | |
| P4kL0nc4t | 24/05/2018 | | |
+-----------------------------+ | |
""") | |
if len(sys.argv) != 2: | |
print("usage: %s <mailist.txt>" % sys.argv[0]) | |
sys.exit(-1) | |
per_mail = (mail.rstrip().split("@") for mail in open(sys.argv[1], "r").readlines() if mail.rstrip() != "") | |
result_dict = {} | |
for mail in per_mail: | |
if len(mail) != 2: | |
continue | |
if mail[1] in result_dict: | |
result_dict[mail[1]].append("%s@%s" % (mail[0], mail[1])) | |
else: | |
result_dict[mail[1]] = ["%s@%s" % (mail[0], mail[1])] | |
for key, value in result_dict.items(): | |
for mail in value: | |
f = open(key+".txt", "a") | |
f.write(mail + "\n") | |
f.close() | |
print("(%s) %s.txt -> %d emails written!" % (key, key, len(result_dict[key]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment