Python: How to read file and store certain columns in array
<p>I am reading a dataset (separated by whitespace) from a file. I need to store all columns apart from last one in the array <code>data</code>, and the last column in the array <code>target</code>.</p>

<p>Can you guide me how to proceed further?</p>

<p>That's what I have so far:</p>

<pre><code>with open(filename) as f:
    data = f.readlines()
</code></pre>

<p>Or should I be reading line by line?</p>

<p>PS: The data type of columns is also different. </p>

<p><strong>Edit:</strong> Sample Data</p>

<pre><code>faban       1   0   0.288   withspy
faban       2   0   0.243   withoutspy
simulated   1   0   0.159   withoutspy
faban       1   1   0.189   withoutspy
</code></pre>