Last active
December 17, 2015 17:28
-
-
Save luiseduardobrito/5645834 to your computer and use it in GitHub Desktop.
Python script for cleaning a csv based on a ban list. (Used to clean big email lists)
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
import csv, sys, random | |
# num = qtd de emails a escolher | |
num = 40000 | |
csv_file = "lista.csv" | |
out_file = "output.csv" | |
email_list = list(csv.reader(open(csv_file, 'r'))) | |
result = [] | |
for i in range(int(num)): | |
result.append(email_list.pop(random.choice(range(len(email_list))))) | |
with open(out_file, "wb") as f: | |
writer = csv.writer(f) | |
writer.writerows(result) | |
with open(csv_file, "wb") as f: | |
writer = csv.writer(f) | |
writer.writerows(email_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment