title: Reading complex data into numpy array
body: <p>I need to read complex numbers from a text file into a numpy array. My question is similar to this one <a href="https://stackoverflow.com/questions/23231698/writing-and-reading-complex-numbers-using-numpy-savetxt-and-numpy-loadtxt">Writing and reading complex numbers using numpy.savetxt and numpy.loadtxt</a> however, the solution here is to alter the format the data is saved in. I don't have this luxury as the text file is generate by other software which I cannot change. A sample of the text file is a follows:</p>
  
  <pre><code>25 + 0i
  8.43818 + -4.94194i
  4.46817 + -5.08305i
  4.55764 + -3.02201i
  2.69138 + -5.43104i
  -0.151334 + -4.83717i
  1.98336 + -1.3339i
  3.59002 + -0.932973i
  1.42727 + -0.617317i
  1.02005 + -1.14214i
  -0.15564 + 2.74564i
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>np.loadtxt('file.txt',delimiter='\n',dtype=np.complex128)
  </code></pre>
  
  <p>However I get the error:</p>
  
  <pre><code>ValueError: complex() arg is a malformed string
  </code></pre>
  
  <p>The posts I have read suggest this is an issue with the <code>+ -</code> notation in some lines, however, I get the same error even if the extra <code>+</code> signs are removed.</p>