title: Text file whitespace can`t be removed in Python
body: <p>I have a text file that is ordered in this fashion:</p>
  
  <pre><code>1,1,1,
  1,1,1,
  1,1,1,
  </code></pre>
  
  <p>My Python script will read each individual line in the text file as a string, delimit based on comma, then convert it to a decimal number for graphing and analysis. I want to create a single array composed of the merged lines such as below: </p>
  
  <pre><code>[1,1,1
   1,1,1
   1,1,1]
  </code></pre>
  
  <p>I`ve tried using the vstack method from numpy but it seems that there is a whitespace leftover in the text file that I cannot get rid of.</p>
  
  <pre><code>&gt;&gt;&gt; 
  [735019.6277, 0.0, 1.0178, 3.0, -2.104]
  [735019.6278, 0.0, 15.361, 3.0, -2.078]
  [735019.628, 0.0, 29.579, 3.0, -2.0682]
  []
  </code></pre>
  
  <p>Because of this space, I cannot join each line into a single array.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>from numpy import *
  from scipy import *
  
  file = open("results_test.txt", 'r')
  line = file.readline()
  data = line.split(',')
  data[-1] = 0
  table = data
  x = 0
  while (x &lt; len(table)):
      table[x] = float(table[x])
      x = x+1
  del(table[-1])
  print table
  
  while line:
      line = file.readline()
      data = line.split(',')
      data[-1] = 0
      x = 0
      while (x &lt; len(data)):
          data[x] = float(data[x])
          x = x+1
      del(data[-1])
      print data
      table = vstack((table,data))
  
  file.close()
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\read_txt.py", line 26, in &lt;module&gt;
      table = vstack((table,data))
    File "C:\Python27\lib\site-packages\numpy\core\shape_base.py", line 226, in vstack
      return _nx.concatenate(map(atleast_2d,tup),0)
  ValueError: array dimensions must agree except for d_0
  </code></pre>
  
  <p>Any thoughts on what this space is and how to get rid of it so that I may use the vstack method?</p>