Numpy: Read csv, deal with undefined values
<p>What is the best way to read data from a csv file into a numpy array when some of the values are labelled as 'undefined' as follows:</p>

<pre><code>0.231620,0.00001,444.157
0.225370,--undefined--,1914.637
0.237870,0.0003,--undefined--
</code></pre>

<p>I have a lot of these files that I will have to loop over, and it is fine to assume that an undefined value should be zero.</p>

<p>No need for Pandas, just use Numpy.</p>

<pre><code>import numpy as np
x = np.genfromtxt('data.csv', dtype=np.float, delimiter=',',
    missing_values='--undefined--', filling_values=0.0,
    )
</code></pre>

python csv numpy