Wednesday, February 26, 2020

Check if email contains double "@" character

An email that is correctly written should contain just a single '@' string. Here I have a scenario where am working on over 18,000 email addresses and for whatever reason some of them have the "@" character appearing more that once.

I started to look through manually and quickly for I went deep my eyes became uncomfortable. Then I new, a bot has to come to my rescue.

So, I have to write a python script that will help you lookup each email and return those who have more than one "@" character.


for email in df['column_title']:
    if str(email).count('@') >= 2:

I just read the email table into a pandas datafarme and used the python count() function to count the occurrences of "@" in each email string.

If the occurrences of "@" is greater or equal to two, the if conditional statement will catch it.

Note: You can replace '@' with any other string of character you want to lookup.


No comments:

Post a Comment