title: Convert a text file to a numpy array
body: <p>I am trying to convert a list of strings into an array. The list is really an array of numbers that is n rows long by 4 columns that I took from a text file. I need to convert this list to an array that is n rows by 4 columns and is floating type. Below is my code so far:</p>
  
  <pre><code>#Calculate the average velocity through a tidal cycle
  
  from pylab import *
  import numpy as np
  
  #Open profile1.ele and get the data
  lookup = '##'
  data = []
  eleline = []
  
  with open('profile1.ele') as f:
  for line in f:
      if not line.startswith(lookup):   #disclude lines with '##'
          data.append(line.rstrip("\r\n"))  
      if 'Elements' in line:
          eleline.append(line)
  s = ''.join(eleline)   #Convert list to string
  numele = s.rsplit()[-2] #Grab # of elements
  numele = int(numele) #convert to integer
  
  #Convert data list object into an array
  elements = np.asarray(data)   
  </code></pre>
  
  <p>This is where I am having problems. The resultant array    is a 1D array with all the information from each line in the list jumbled together. </p>
  
  <p>Here is an example of the input file format. </p>
  
  <pre><code>## =============================================================================
  ## TIME STEP      1         Duration:  6.0000E+02 sec      Time:  3.4712E+09 sec
  ## =============================================================================
  ##      X origin       Y origin     X velocity     Y velocity
     3.1225530E-01 -9.5153722E+00  4.8239441E-09 -1.1614215E-08
     4.0205122E-01 -8.5404981E+00  1.7396887E-09 -1.8665899E-08
     4.3224251E-01 -7.5565436E+00  2.0985602E-09 -2.5349955E-08
     4.3234870E-01 -6.5693932E+00  1.7166213E-09 -3.1156361E-08
     4.2276193E-01 -5.5905580E+00  1.9627062E-09 -3.7317066E-08
     4.0245047E-01 -4.6585868E+00  1.7305504E-09 -4.3153198E-08
     3.6284562E-01 -3.8494609E+00  1.7422198E-09 -4.8249619E-08
     3.1234937E-01 -3.1767707E+00  1.9901861E-09 -5.3221055E-08
     2.6726067E-01 -2.5743939E+00  1.9799420E-09 -5.8343627E-08
     2.2791616E-01 -2.0380240E+00  1.7150138E-09 -6.3250542E-08
     1.8285348E-01 -1.5997592E+00  9.9428594E-10 -6.7249257E-08
  </code></pre>
  
  <p>I want an array (11 x 4) of this data as a floating point. Example:</p>
  
  <pre><code>   3.1225530E-01 -9.5153722E+00  4.8239441E-09 -1.1614215E-08
     4.0205122E-01 -8.5404981E+00  1.7396887E-09 -1.8665899E-08
     4.3224251E-01 -7.5565436E+00  2.0985602E-09 -2.5349955E-08
     4.3234870E-01 -6.5693932E+00  1.7166213E-09 -3.1156361E-08
     4.2276193E-01 -5.5905580E+00  1.9627062E-09 -3.7317066E-08
     4.0245047E-01 -4.6585868E+00  1.7305504E-09 -4.3153198E-08
     3.6284562E-01 -3.8494609E+00  1.7422198E-09 -4.8249619E-08
     3.1234937E-01 -3.1767707E+00  1.9901861E-09 -5.3221055E-08
     2.6726067E-01 -2.5743939E+00  1.9799420E-09 -5.8343627E-08
     2.2791616E-01 -2.0380240E+00  1.7150138E-09 -6.3250542E-08
     1.8285348E-01 -1.5997592E+00  9.9428594E-10 -6.7249257E-08
  </code></pre>