-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemailchecker.py
31 lines (23 loc) · 925 Bytes
/
emailchecker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
def extract_emails_from_file(file_path):
if file_path.endswith('.csv'):
df = pd.read_csv(file_path)
elif file_path.endswith('.xlsx'):
df = pd.read_excel(file_path)
else:
print("Unsupported file format")
return
# adjust column name as needed
emails = df['email']
# extract username and domain
email_parts = [email.split('@') for email in emails]
usernames = [parts[0] for parts in email_parts]
domains = [parts[1] for parts in email_parts]
new_df = pd.DataFrame({'Username': usernames, 'Domain': domains})
# new CSV file
new_file_path = 'extracted_emails.csv'
new_df.to_csv(new_file_path, index=False)
print(f"Extracted emails saved to {new_file_path}")
# path file containing emails
file_path = 'EmailChecker.csv' # Change this to your file's path
extract_emails_from_file(file_path)