A RAM error of big array

Posted by flint on Stack Overflow See other posts from Stack Overflow or by flint
Published on 2010-03-12T12:05:22Z Indexed on 2010/03/12 12:07 UTC
Read the original article Hit count: 239

Filed under:

I have a big file, more than 400M. In that file, there are 13496*13496 number, means 13496 rows and 13496 cols. I want to read them to a array. This is my code:

_L1 = [[0 for col in range(13496)] for row in range(13496)]
_L1file = open('distanceCMD.function.txt')
while (i<13496):
    print "i="+str(i)
    _strlf = _L1file.readline()
    _strlf = _strlf.split('\t')
    _strlf = _strlf[:-1]
    _L1[i] = _strlf
    i += 1
_L1file.close()

And this is my error massage:

MemoryError:
File "D:\research\space-function\ART3.py", line 30, in <module>
  _strlf = _strlf.split('\t')

© Stack Overflow or respective owner

Related posts about python