A Python automation script developed as part of the CodeAlpha Python Programming Internship (Task 3: Task Automation with Python Scripts).
This tool scans any .txt file, automatically detects and extracts all valid email addresses using regular expressions, removes duplicates, and saves a clean list to a new output file β a common real-life automation task for handling reports, contact lists, or scraped text data.
- π Scans any
.txtfile for email addresses - π Uses regex pattern matching to reliably detect valid email formats
- π§Ή Automatically removes duplicate emails
- π€ Sorts results alphabetically
- πΎ Saves extracted emails to a new
.txtfile, with date and total count - π Option to scan multiple files in one session
- π¨ Optional colored terminal interface (works without Colorama as well)
- β Input validation and friendly error messages
- Python 3
re(Regular Expressions)osModuledatetime- Colorama (Optional)
CodeAlpha_EmailExtractor/
βββ email extractor.py
βββ README.md
Output files (e.g.
extracted_emails.txt) are generated automatically each time you run the script and are not part of the repository.
- Make sure Python 3 is installed.
- Download or clone this repository.
- Open the project folder in your terminal.
- Run the following command:
python "email extractor.py"Note: since the filename contains a space, it must be wrapped in quotes when running it from the terminal.
- When prompted, enter the path to the
.txtfile you want to scan (e.g.sample.txtif it's in the same folder, or a full path likeC:\Users\dell\Downloads\emails.txt).
Optional: Install Colorama for a colored terminal interface.
pip install coloramaThe application also works correctly without Colorama (plain text mode).
This project demonstrates the use of:
- Regular Expressions (
remodule) - File Handling (reading and writing
.txtfiles) - Set Operations (removing duplicates)
- Exception Handling
- Modular Programming
- User Input Validation
Saleha Shahid BS Electrical Engineering University of Management and Technology (UMT)
CodeAlpha β Python Programming Internship