Coders Packet

Python Source Code for Email Extraction from user input

By SALONI VERMA

This is a small project designed in Python of email extraction in which it takes input from users and lists all the emails present in the input. Input will be paragraph of any length.

If I want to segregate the emails from a paragraph in a website, I have to read all the lines carefully and also it is very time-consuming.

This is a small project of email extraction in which it takes input from the user and lists all the emails present in the input. Input will be a paragraph of any length.

It is programmed in Python.

It uses-

1. RE module (Regular Expression)

2. Loops

3. Lists

 

In this program, I have used a list which later on appends all the text in itself and then provided a RE find all function which segregates emails from the whole text. and then create a text file and write all email names. And then prints all the email names and count of emails.

import re
text = []
print("Enter or paste the garbage paragraph from which you want to know the emails :")
while True:
    line = input()
    if line:
        text.append(line)
    else:
        break
string = '\n'.join(text)

list1=re.findall(r'\[email protected]\S+\w',string)

op=open("email_store.txt","a")
j=1
for i in list1:
    op.write(f"Email{j}:{i}\n")
    j=j+1
op.close()
print("Email's are:")
for i in list1:
    print(i)
print(f"\nTotal Email's are : {j-1}")

 

Download Complete Code

Comments

No comments yet