title: Read a .txt file as an array and obtain value of a specified index in Python
body: <p>I have a big .txt data file with the format like (all numbers):</p>
  
  <pre><code>0 1.2 2 3.1
  20 21.2 22 23
  30 31 32 33.01
  </code></pre>
  
  <p>I want to import the 2nd column, for example, of this matrix into a variable. Here is the code that I have wrote. First, I import all the matrix into a variable as string and convert it into an array, named "data" here. Then, want to access data[1][1] or data[:][1] But, it gives the following error </p>
  
  <blockquote>
    <p>IndexError: too many indices for array</p>
  </blockquote>
  
  <p>Any idea what is the error or what is the efficient way of doing the job? Many thanks</p>
  
  <pre><code>import csv
  data=[]
  with open('test.txt', 'r') as f:
    reader = csv.reader(f, delimiter=' ', skipinitialspace=True)
     for line in f:
        if line.endswith('\n'):
            line=line[:-1] 
  
        data=np.asarray(line)  
        print(data)
  </code></pre>