Skip to content

Instantly share code, notes, and snippets.

@jason-feng
Created March 29, 2017 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jason-feng/b0737802ddc3694896b83a098b69d5c1 to your computer and use it in GitHub Desktop.
Save jason-feng/b0737802ddc3694896b83a098b69d5c1 to your computer and use it in GitHub Desktop.
Formats emails nicely for slack
## Turns list of dartmouth emails into formatted emails with first and last name
f = open("names.txt")
o = open("names_edit.txt", 'w')
for email in f.readlines():
email = email.strip()
email = email[:-1] # Remove semicolon
bracket_email = "<" + email + ">" # Now its like <jason.s.feng.17@dartmouth.edu>
at_index = email.rfind("@")
name = email[0:at_index-3] # get just the jason.s.feng
name_array = name.split(".")
first_name = name_array[0]
last_name = name_array[len(name_array)-1]
formatted_email = first_name + " " + last_name + " " + bracket_email + ", "
o.write(formatted_email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment