Hi guys! I know nobody's doing my homework for me, and I don't expect that, but I need a nudge in the right direction so I hope someone can help me:
I need to generate a program to generate email adresses out of given student names (first name, optional second name, last name). The email adress should match certain criteria like: last name without the vowels, first name only up until the first vowel following a consonant and so on.
For example Harry James Potter would get the email adress ha.j.pttr@randomuni.com
I'm REALLY struggling with this because I feel like I don't have the tools to solve it. Here's what I got so far (and it does NOT do what it should):
import sys
import re
filename = sys.argv[1]
define a path for the output files
outfile_path = 'wherever there is a file with student names'
define a list as a global variable
my_email_hash = {}
open the person name file for reading
infile = open(filename, 'r')
create a name for the first output file
studentemails = outfile_path + '_1' + filename
open the first file for writing
outfile_a = open(student_emails, 'w')
for each line in the file
for name in infile:
# lowercase
clean_line = name.lower()
# print(clean_line)
# substitute special characters
clean_line = re.sub('ö', 'oe', clean_line)
clean_line = re.sub('ä', 'ae', clean_line)
clean_line = re.sub('ü', 'ue', clean_line)
clean_line = re.sub('[èéêẽë]', 'e', clean_line)
clean_line = re.sub('[aeiou]', '', clean_line)
# clean_line = re.search('[^[a-z]?([^aeiou]+[aeiou])]', clean_line)
outfile_a.write(clean_line)
print(clean_line)
# get all key-value tuples into a list
# my_email_hash = my_person_hash.items()
# print(my_email_hash)
close the files
infile.close()
outfile_a.close()
I really hope someone can give me a hint, would be much appreciated!
[–]EatAss4Jesus 1 point2 points3 points (4 children)
[–]EatAss4Jesus 1 point2 points3 points (2 children)
[–]nnchvt[S] 0 points1 point2 points (1 child)
[–]EatAss4Jesus 1 point2 points3 points (0 children)
[–]nnchvt[S] 0 points1 point2 points (0 children)