Read numbers from formatted file in Python
Question: I have file with k columns of numbers (same number of elements for each
columns). What is the fastest way to read it and save the numbers in each
column in a separate numpy.array?


Answer: Try using
[`genfromtxt`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html).

This has the benefit of you being able to specify column names if you like, or
even read into a `recarray`.

I made a file 'tmp':

    
    
    1 2 3 4 5
    6 7 8 9 10
    11 12 13 14 15
    

Then from numpy:

    
    
    import numpy as np
    data = np.genfromtxt('tmp')
    #array([[  1.,   2.,   3.,   4.,   5.],
    #       [  6.,   7.,   8.,   9.,  10.],
    #       [ 11.,  12.,  13.,  14.,  15.]])
    

If you look at `help(np.genfromtxt)` you'll see there are various options like
specifying custom `dtype`s (so you can make a recarray if you want), setting
options for missing values, reading in column names, etc.

