title: How to read space-separated data into a numpy array?
body: <p>I have a text file with numbers separated by spaces, such as:</p>
  <pre><code>-2 -3 4 -1 -2 1.5 -3
  </code></pre>
  <p>I tried to create an numpy array with the file elements using the following code:</p>
  <pre><code>root = tk.Tk()
  root.withdraw()
  A = np.array([])
  arquivox = filedialog.askopenfilename()
  # reading datafile
  with open(arquivox, &quot;r&quot;) as f:
      for termox in f:
          # specifying the separator
          termox = termox.split(' ')
          # converting the elements to float and generating the array
          A = np.append(A, float(termox[0]))
  print(A)
  </code></pre>
  <p>However, I am only saving the first element of the file (-2). What am I doing wrong?</p>