The numpy.loadtxt function has a parameter usecols. From the documentation:
numpy.loadtxt(
fname,
dtype=<type 'float'>,
comments='#',
delimiter=None,
converters=None,
skiprows=0,
usecols=None,
unpack=False,
ndmin=0
)
Load data from a text file.
...
usecols : sequence, optional Which columns to read, with 0 being
the first. For example, usecols = (1,4,5) will extract the
2nd, 5th and 6th columns. The default, None, results in all
columns being read.
Of course this presumes you know in advance how many columns are in the file.
For example, given the following file test.txt:
100 test1
200 test2
300 test3
Loading with numpy.loadtxt("test.txt") produces this error.
$ python -c "import numpy as np;np.loadtxt('test.txt')"
Traceback (most recent call last):
...
items = [conv(val) for (conv, val) in zip(converters, vals)]
ValueError: could not convert string to float: test1
However using the usecols parameter works fine:
$ python -c "import numpy as np;print np.loadtxt('test.txt', usecols=(0,))"
[ 100. 200. 300.]