Created
March 7, 2020 08:26
-
-
Save PandaWhoCodes/26f21f8bb4f55e817b97556062b9e59a to your computer and use it in GitHub Desktop.
Code to verify emails from a given csv file
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
# pip install verify-email (before running this) | |
import pandas as pd | |
from verify_email import verify_email | |
import pickle | |
final_row = ["S.No", "Name of Student", "Email", "valid"] | |
def get_file(filename): | |
return pd.read_csv(filename) | |
def validate(email): | |
value = verify_email(email) | |
return str(value) | |
def validate_all_mails(df): | |
rows = [] | |
num = 1 | |
#Change the column number here / add more columns | |
for ind in df.index: | |
rows.append( | |
[df[final_row[0]][ind], df[final_row[1]][ind], df[final_row[2]][ind], validate(df[final_row[2]][ind])]) | |
print(num) | |
num = num + 1 | |
return rows | |
if __name__ == '__main__': | |
file = get_file("kcg_emails.csv") | |
rows = validate_all_mails(file) | |
with open("obj", "wb") as f: | |
pickle.dump(rows, f) | |
df = pd.DataFrame(rows, columns=final_row) | |
df.to_csv("final_emails_verified.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment