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.


Platform Version Package Size
All (Python) 1.1 – 2011-02-14 (right-click -> Save as…) 1.8 KB
Git repository Development


python <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.


  • python contacts.csv — returns all email addresses from contacts.csv, displaying one email address per line
  • python contacts.csv , — returns a comma-separated list of all email addresses in contacts.csv
  • python contacts.csv space — returns all email addresses from contacts.csv, separated by a space
  • python contacts.csv ; > emails.txt — writes all of the email addresses from contacts.csv, separated by a semi-colon, to emails.txt
  • python utf8-contacts.csv newline utf-8 — returns all email addresses, one per line, from the UTF-8 encoded file utf8-contacts.csv



  • 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 — is as valid as
  • Google CSV files use UTF-16 encoding by default; specify utf-16 as the encoding to process them correctly


EmailsFromFile is licensed under the WTFPL.