[Numpy-discussion] Simple Loadtxt question
Derek Homeier
derek at astro.physik.uni-goettingen.de
Wed Nov 28 19:29:27 EST 2012
On 29.11.2012, at 1:21AM, Robert Love wrote:
> I have a file with thousands of lines like this:
>
> Signal was returned in 204 microseconds
> Signal was returned in 184 microseconds
> Signal was returned in 199 microseconds
> Signal was returned in 4274 microseconds
> Signal was returned in 202 microseconds
> Signal was returned in 189 microseconds
>
> I try to read it like this:
>
>
> data = np.loadtxt('dummy.data', dtype={'names':('label','times','musec'), 'fmts':('|S23','i8','|S13')})
>
> It fails, I think, because it wants a string format and field for each of the words 'Signal' 'was' 'returned' etc.
>
> Can I make it treat that whole string before the number as one string, one field? All I really care about is the numbers anyway.
>
Then how about
np.loadtxt('dummy.data', usecols=(4, ))
Cheers,
Derek
More information about the NumPy-Discussion
mailing list