[SciPy-User] How To Use Loadtxt For Floats And Strings?

Joseph Smidt josephsmidt@gmail....
Sat Jun 12 11:55:59 CDT 2010


Hello,

    I have a file with the following data:

      0.227045E-01    0.610229E-03     \Omega_b h^2
      0.110213E+00    0.550143E-02     \Omega_{DM} h^2
      0.103980E+01    0.263806E-02     \theta
      0.893775E-01    0.147515E-01     \tau

I would like to load all three columns into three arrays. (The first
two being floats and the third a string,)  Can't I use loadtxt for
this?  I tried using this command:

a, b, c = loadtxt('myfile.txt',unpack=True,dtype=(float,float,'S16'))

I must be doing something wrong.  What is the proper expression for
loadtxt?  Or must I use something else?  Thanks!

-- 
------------------------------------------------------------------------
Joseph Smidt <josephsmidt@gmail.com>

Physics and Astronomy
4129 Frederick Reines Hall
Irvine, CA 92697-4575
Office: 949-824-3269


More information about the SciPy-User mailing list