comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Maddening structures
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Maddening structures [message #50286 is a reply to message #50226] Tue, 19 September 2006 11:04 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 18 Sep 2006 11:47:23 +0000, Edd wrote:

> OK, I've got some data read in so that I have a structure that looks
> like
>
> data.foo[600]
> .bar[600]
> .baz[600]
>
> and I want
> data[600].foo
> .bar
> .baz
>
> In other words I want an array of structures rather than a structure
> of arrays.
>
> Does anyone have any magic that works for the case when foo, bar and
> baz are not previously known?

Read in the field names (from your file) into a string array "fields",
and the first set of values into a pointer array "vals", and then create
an array of structures like this:

st=create_struct(fields[0],*vals[0])
for i=1,nfields-1 do $
st=create_struct(st,fields[i],*vals[i])
st=replicate(st,ndata)

If your file format describes the type of each field (float, int,
string, etc.), you can parse that and make an appropriate vals pointer
array from it, rather than divining it from the data themselves (which
is more likely to give trouble).

JD
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: spawn and 'ls *.out'
Next Topic: plot: Messed-up coordinates when switching devices

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 16:19:57 PDT 2025

Total time taken to generate the page: 1.35814 seconds