Question 9
Back to Exercise
What is the most memory-efficient way to process a 5 GB log file?
- A data = f.read()
- B lines = f.readlines()
- C Open it in "w" mode
- D for line in f: … (one line at a time) Correct
Correct Answer: Option D
read() and readlines() load the whole file into memory.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!