A Python Script

Mail Bale

Copying email lists for alert groups manually is painful. Having to format that list by hand is even worse.

I made this script to take a list of email and format it with brackets and commas so that it is ready to be consumed by PgAdmin into a database.

Fork Mail Bale
input a list like this:
          
  user1@user1.com
  user2@user2.com
  user3@user3.com
          
and get output like this:
          
  {user1@user1.com, user2@user2.com, user3@user3.com}
          
        
These are the files

process_email_groups.py

# This is the file that we will read.
  raw_email_data = 'raw_email_data.txt'

  # Open the file here and perform any operations necessary.
  with open(raw_email_data, 'r') as data_file:
    read_data = data_file.read().splitlines()
    processed_data = ', '.join(read_data)

  print('{' + processed_data + '}')

raw_email_data.text

Paste your email list in the file. When the script runs it will read from here, and output in the command line.

Soon this will output in the same file.