 <pre><code>import numpy a_width = 9 a_height = 9 data_file = "matrix.dat" a = numpy.array(open(data_file).read().split(),dtype=int).reshape((a_width,a_height)) #or another alternative below a = numpy.fromfile("matrix.dat",dtype=int,sep=" ").reshape(9,9) print a </code></pre> <p>a different solution</p> <pre><code>with open(data_file) as f: a = map(str.split,f) print a </code></pre> <p>which is just a slightly more terse version of Nick Burns Code </p>