[Numpy-discussion] genfromtxt to structured array

Ryan May rmay31@gmail....
Fri Sep 25 16:40:17 CDT 2009


On Fri, Sep 25, 2009 at 4:30 PM, Timmie <timmichelsen@gmx-topmail.de> wrote:
> Hello,
> this may be a easier question.
>
> I want to load data into an structured array with getting the names from the
> column header (names=True).
>
> The data looks like:
>
>    ;month;day;hour;value
>    1995;1;1;01;0
>
>
> but loading only works only if changed to:
>
>    year;month;day;hour;value
>    1995;1;1;01;0
>
>
> How do I read in the original data?

There's an assumption that the number of names is the same as the
number of columns.  You can just specify the names and skip reading
the names from the file:

numpy.genfromtext(filename, delimiter=';', skiprows=1, names=['year',
'month', 'day', 'hour', 'value'])

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States


More information about the NumPy-Discussion mailing list