I'm a newbie to Python and currently I have a text file which looks like this:
# Wed 13:10:08 11-Mar-2015
begin aperture image1 1 1024. 139.7445
image image1
aperture 1
beam 1
center 1024. 139.7445
low -1023. -4.
high 1024. 4.
background
xmin -40.45428
xmax 43.75221
function chebyshev
order 3
sample -40.45428:-18.42313 20.09063:43.75221
naverage 1
niterate 0
low_reject 3.
high_reject 3.
grow 0.
axis 2
curve 6
2.
2.
4.
2044.
-0.1275881
-0.03320996
I want to extract '139.7445' from the sixth row ('center'). This is my code:
pos_wasp = np.loadtxt(line, skiprows=5, usecols=(3,4), unpack=True)
But when I run it, it gives an error:
IndexError: list index out of range
It should be a simple problem to solve and I've been trying to change the column numbers and the data types many times, but it still doesn't work.
np.genfromtxt(line, skip_header=5, skip_footer=21, usecols=(1,2), unpack=True)will extractarray([1024., 139.7445]).usecolsvalue. Giving us more of the error message (lines etc) would clarify that. But more importantly this not the kind of file thatloadtxt/genfromtxtis meant to handle.