-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week4 hienhpss #51
base: master
Are you sure you want to change the base?
Week4 hienhpss #51
Conversation
@@ -0,0 +1,5 @@ | |||
fname,lname,email |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this. You need to submit your code only.
@@ -0,0 +1,5 @@ | |||
fname,lname,email |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this. You need to submit your code only.
@@ -0,0 +1,2 @@ | |||
Bill Gates <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this. You need to submit your code only.
print('{:s} {:s} <{:s}>'.format(str(person['fname']),str(person['lname']),str(person['email']))) | ||
|
||
if __name__ == "__main__": | ||
week4_output() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always have a new line at the end of your code files.
@@ -0,0 +1,56 @@ | |||
import csv | |||
from csv import Dialect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see you using Dialect
m.update(i_enc) | ||
return m.digest() | ||
|
||
def week4_csv_to_dict(csv_rows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't call it week4, give it some meaningful name.
if source1[key]['fname'] == source2[key]['fname'] and source1[key]['lname'] == source2[key]['lname']: | ||
yield(source1[key]) | ||
|
||
def week4_output(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't call it week4, give it some meaningful name.
return result | ||
|
||
|
||
def week4_match_sources(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't call it week4, give it some meaningful name.
yield(source1[key]) | ||
|
||
def week4_output(): | ||
'''Outout list of duplicate guests to file''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling error
def week4_match_sources(): | ||
'''Match the 2 input file and return the people | ||
who subscribe to both''' | ||
file1 = sys.argv[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather pass 2 file names to this function. Avoid accessing sys.argv
to make this function reusable.
for row in csv_reader: | ||
yield(row) | ||
|
||
def generate_md5(*args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition says each guest has only a single email, so you don't need md5, right? Have a cup of tea and think about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally it makes sense to use generators here hehe. Make some updates please ;)
for key in set(source1.keys()): | ||
if key in set(source2.keys()): | ||
if source1[key]['fname'] == source2[key]['fname'] and source1[key]['lname'] == source2[key]['lname']: | ||
yield(source1[key]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats! Finally you have a valid reason to use generators ;)
Week 4 solution