title: Fastest way to create a numpy array from text file
body: <p>I have 60mb file with lots of lines.</p>
  
  <p>Each line has the following format:</p>
  
  <pre><code>(x,y)
  </code></pre>
  
  <p>Each line will be parsed as a numpy vector at shape (1,2).</p>
  
  <p>At the end it should be concatenated into a big numpy array at shpae (N,2)
  where N is the number of lines.</p>
  
  <p>What is the fastest way to do that? Because now it takes too much time(more than 30 min).</p>
  
  <p>My Code:</p>
  
  <pre><code>with open(fname) as f:
  for line in f:
      point = parse_vector_string_to_array(line)
      if points is None:
          points = point
      else:
          points = np.vstack((points, point))
  </code></pre>
  
  <p>Where the parser is:</p>
  
  <pre><code>def parse_vector_string_to_array(string):
      x, y =eval(string)
      array = np.array([[x, y]])
      return array
  </code></pre>