EmailsFromFile
EmailsFromFile is a Python script that extracts all email addresses from a file. It follows a regular expression pattern based on the RFC 2822 standard and should thus return all valid email addresses regardless of how they appear in the file. For example, EmailsFromFile will distinguish between separate email addresses in a comma-separated list of values, such as a CSV file containing names, addresses, phone numbers and email addresses.
Download
Platform | Version | Package | Size |
---|---|---|---|
All (Python) | 1.1 – 2011-02-14 | emailsfromfile.py (right-click -> Save as…) | 1.8 KB |
Git repository | Development | https://github.com/patrickmn/emailsfromfile |
Usage
python emailsfromfile.py <filename> [separator] [encoding]
The separator and encoding parameters are optional. The separator is a new line and the file encoding is 8-bit ASCII by default. If you want to specify an encoding, you also have to set a separator; to use a new line (the default), specify newline
as the separator.
Examples:
-
python emailsfromfile.py contacts.csv
— returns all email addresses from contacts.csv, displaying one email address per line -
python emailsfromfile.py contacts.csv ,
— returns a comma-separated list of all email addresses in contacts.csv -
python emailsfromfile.py contacts.csv space
— returns all email addresses from contacts.csv, separated by a space -
python emailsfromfile.py contacts.csv ; > emails.txt
— writes all of the email addresses from contacts.csv, separated by a semi-colon, to emails.txt -
python emailsfromfile.py utf8-contacts.csv newline utf-8
— returns all email addresses, one per line, from the UTF-8 encoded file utf8-contacts.csv
Requirements
- Python 2.4 or greater.
Notice
- Each email address is shown only once
- EmailsFromFile does not check whether an email address is valid beyond the standard format defined by RFC 2822, i.e. whether the domain or top-level domain are valid — [email protected] is as valid as [email protected]
-
Google CSV files use UTF-16 encoding by default; specify
utf-16
as the encoding to process them correctly
License
EmailsFromFile is licensed under the WTFPL.