Taking file input in numpy Matrix
<p>I am unable to find a method to take input of a given file in numpy matrix. 
I have tried the <code>np.loadtxt()</code> but was unable to get the data.</p>

<p>My file format is something like this: 
Number of col = 9 (except the first field all others are in float).</p>

<pre><code>M,0.475,0.37,0.125,0.5095,0.2165,0.1125,0.165,9
F,0.55,0.44,0.15,0.8945,0.3145,0.151,0.32,19
</code></pre>

<p>I have also tried taking input in a list and then trying to make it numpy matrix but it was also a failure. </p>

<p>You might want to consider using <code>pandas</code> instead - it's much better suited to homogeneous data, and its <code>read_csv</code> function will take your data file and convert it immediately to something you can work with.</p>

<p>You can give each column a name - if you don't do this, the function will interpret the first data row as column headings.</p>

<pre><code>&gt;&gt;&gt; import pandas as pd
&gt;&gt;&gt; data = pd.read_csv("/tmp/data.txt",
                 names=['sex', 'one', 'two', 'three', 'four',
                        'five', 'six', 'seven', 'eight'])
&gt;&gt;&gt; print(data)
  sex    one   two  three    four    five     six  seven  eight
0   M  0.475  0.37  0.125  0.5095  0.2165  0.1125  0.165      9
1   F  0.550  0.44  0.150  0.8945  0.3145  0.1510  0.320     19
</code></pre>

python numpy