I wish to read a large data file (file size is around 1.8 MB) and manipulate the data in this file. Just reading and writing the first 500 lines of this file is causing a problem. I wrote:<br><br>fin = open('gene-GS00471-DNA_B01_1101_37-ASM.tsv')<br>
count = 0<br>for i in fin.readlines():<br> print i<br> count += 1<br> if count >= 500:<br> break<br><br>and got this error msg:<br><br>Traceback (most recent call last):<br> File "H:\genome_4_omics_study\GS000003696-DID\GS00471-DNA_B01_1101_37-ASM\GS00471-DNA_B01\ASM\gene-GS00471-DNA_B01_1101_37-ASM.tsv\test.py", line 3, in <module><br>
for i in fin.readlines():<br>MemoryError<br><br>-------<br><span dir="ltr" id=":3a">is there a way to stop python from slurping all the file contents at once</span>?<br><br><br><br><br>