Skip to content

Instantly share code, notes, and snippets.

@realmayus
Last active February 11, 2020 21:30
Show Gist options
  • Save realmayus/c668ff0e49fe14d55102aec1c00a2077 to your computer and use it in GitHub Desktop.
Save realmayus/c668ff0e49fe14d55102aec1c00a2077 to your computer and use it in GitHub Desktop.
Takes a list of Email addresses along with names in the format "Name Name <email@email.com>\n" and converts them to a CSV file that you can import into google contacts.
with open('contacts.csv', 'a') as newF:
newF.write('Name,"E-mail 1 - Value"\n')
newF.close()
with open('contacts.txt') as f:
for line in f:
name, email = line.split('<')
name = name[:-1]
email = email[:-3]
print("Name:" + name + ", Email: " + email + "\n")
with open('contacts.csv', 'a') as newF:
newF.write(name + "," + email + "\n")
newF.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment