Python - How can I store data from a text file without storing all data simultaneously in the primary memory? <p>I have a text file which has an unknown number of lines. Each line is either "0" or "1".</p> <p>I need to analyse the text file, for example I need to find how many 1s and 0s are in the file.</p> <p>So would it be incorrect to do this?</p> <pre><code>fo = open("data.txt", "r") numbers = fo.read().splitlines() fo.close() </code></pre>