Conversation
tianyi21
left a comment
There was a problem hiding this comment.
Hi Diana,
✅ You completed the patient_summary() function to summarize a file.
✅ You implemented the detect_problems() function to check the file.
print() statement and a for loop of print(). All given files contain 60 rows of data. In your version, could you comment on how many times print() statement are called? Is there a better way to read and print the content? You may follow the hint given after # YOUR CODE HERE: ....
Please revise your current submission to address the
Thanks,
Tianyi [LS]
dianayangs
left a comment
There was a problem hiding this comment.
addressed comments from Tianyi
tianyi21
left a comment
There was a problem hiding this comment.
Thank you for the update. In your updated version, you removed the first print statement. In this case, will the first line of the file be printed?
You can use the commented lines as a hint, or alternatively, consider how many lines are in each file and how many print statements are needed to display the file content.
Hi Tianyi, I think I fixed it. Can you explain why my original code would print >60 lines? I was following an example in 08_reading_and_writing_files |
tianyi21
left a comment
There was a problem hiding this comment.
Hi Diana,
Thank you for updating your submission.
✅ Your version is correct! In the meantime, as we seen in the live learning, we may directly read the file with Python built-in/native IO function as follows:
with open(all_paths[0], 'r') as f:
# YOUR CODE HERE: Use the readline() or readlines() method to read the .csv file into a variable
# first = f.readline() # <- not needed here
contents = f.readlines() # <- use native file IO, read everything into contents
# YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection
# contents = csv.reader(f) # <- use native file IO with f above
for row in contents: # <- the same way as how you print the content
print(row)
In this case, we don't have to involve the csv package. However, in more complicated scenarios, please feel free to use any package.
🎉 Your A2 is complete!
🎊 All your Python assessments are now complete. Thank you for your participation, and I wish you all the best for your future!
Thanks,
Tianyi [LS]
|
I see, can you comment:
with open(all_paths[0], 'r') as f: for rows in contents: |
For (1): you may use either the
In this assignment, the files we are working with are quite small so either should be fine. In practice, if the file size is very large, using These are the file IO with Python built-in methods. For more efficient file handling, there are other packages available such as For (2): in this assignment, we are not looking for the best/optimal/cleanest code. As long as your version does what it's required, we will accept it. |
Regarding total number of |
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
changes made are to complete assignment
What did you learn from the changes you have made?
defining functions are much simpler than I would assume
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
Thought I needed more complex code
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
challenges in trusting myself. Also almost submitted a pull request to the main DSI branch OOPS
How were these changes tested?
ran the checks, got expected results
A reference to a related issue in your repository (if applicable)
Checklist