On Sun, Jun 26, 2011 at 2:27 PM, Derek Homeier <
de...@astro.physik.uni-goettingen.de> wrote:

> On 26.06.2011, at 8:48PM, Chao YUE wrote:
>
> > I want to read a csv file with many (49) columns, the first column is
> string and remaning can be float.
> > how can I avoid type in like
> >
> > data=numpy.genfromtxt('data.csv',delimiter=';',names=True, dtype=(S10,
> float, float, ......))
> >
> > Can I just specify the  type of first cloumn is tring and the remaing
> float? how can I do that?
>
> Simply use 'dtype=None' to let genfromtxt automatically determine the type
> (it is perhaps a bit confusing that this is not the default - maybe it
> should be repeated in the docstring for clarity that the default is for
> dtype is 'float'...).
> Also, a shorter way of typing the dtype above (e.g. in case some columns
> would be auto-detected as int) would be
> ['S10'] + [ float for n in range(48) ]
>
>
Another possibility is -- if you don't want the first column string data --
is to basically ignore that column by specifying the "usecol" parameter.

Ben Root
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to