How do I read a text file containing an array and place it in an array? (Python)
Question: 
    from numpy import *
    
    f = open('matrix.txt', 'r')
    
    x = []
    for line in f.readlines():
        y = [value for value in line.split()]
        x.append(y)
    
    f.close()
    
    x = map(int, x)
    
    a = array([x])
    

Basically, my code is suppose to open the text file and put it into the list
x. I then change those values in x into an integer and place that in an array
a. Is there a faster way to do this? Btw my code doesn't work.


Answer: You'll probably do a little better if you use
[`np.loadtxt`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html).

