title: Reading floats inside strings from a file using numpy
body: <p>I have a text file like this:</p>
  
  <pre><code>"-3.588920831680E-02","1.601887196302E-01","1.302309112549E+02"
  "3.739478886127E-01","1.782759875059E-01","6.490543365479E+01"
  "3.298096954823E-01","6.939357519150E-02","2.112392578125E+02"
  "-2.319437451661E-02","1.149862855673E-01","2.712340698242E+02"
  "-1.015115305781E-01","-1.082316488028E-01","6.532022094727E+01"
  "-5.374089814723E-03","1.031072884798E-01","5.510117187500E+02"
  "6.748274713755E-02","1.679160743952E-01","4.033969116211E+02"
  "1.027429699898E-01","1.379162818193E-02","2.374352874756E+02"
  "-1.371455192566E-01","1.483036130667E-01","2.703260498047E+02"
  "NULL","NULL","NULL"
  "3.968210220337E-01","1.893606968224E-02","2.803018188477E+01"
  </code></pre>
  
  <p>I tried to read this textfile using numpy as:</p>
  
  <pre><code>dat = np.genfromtxt('data.txt',delimiter=',',dtype='str')
  print("dat = {}".format(dat))
  
  # now when I try to convert to float
  dat = dat.astype(np.float) # it fails
  
  # try to make it float
  dat = np.char.strip(dat, '"').astype(float)
  </code></pre>
  
  <blockquote>
  <pre><code>File "test.py", line 25, in &lt;module&gt;
      dat = dat.astype(np.float)  # it fails
  ValueError: could not convert string to float: '"-3.588920831680E-02"'
  </code></pre>
  </blockquote>
  
  <p>How can I fix this error?</p>
  
  <p>Related links:</p>
  
  <p><a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html#numpy.genfromtxt" rel="nofollow noreferrer">https://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html#numpy.genfromtxt</a></p>