简体   繁体   中英

Memory Error Python while processing large database

When I run this on Pycharm 4 on windows I got an error in this code:

PDBSumWWW = urllib.urlopen("https://www.ebi.ac.uk/thornton-srv/databases/pdbsum/data/seqdata.dat")
PDBSum = PDBSumWWW.read().splitlines()
PDBSumWWW.close()

This is the error message:

Traceback (most recent call last): File "C:/Users/LuisAlberto/PycharmProjects/MSc/SeqPDBSumIRIndex.py", line 98, in main() File "C:/Users/LuisAlberto/PycharmProjects/MSc/SeqPDBSumIRIndex.py", line 40, in main PDBSum = PDBSumWWW.read().splitlines() MemoryError

However when running in on a Macbook Air it doesnt happen.

how do I get over this?

This is the most simple solution that I can think of to solve your problem.
In this solution the for loop will iterate over every line in the database.
every line will be assigned to the line variable.

PDBSumWWW = urllib.urlopen("https://www.ebi.ac.uk/thornton-srv/databases/pdbsum/data/seqdata.dat")
for line in PDBSumWWW:
    # Do necessary calculations. 
PDBSumWWW.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM