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

Home » Public Forums » archive » Re: "shrink" 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: "shrink" structures [message #69723] Tue, 09 February 2010 23:43 Go to previous message
Johannes Korn is currently offline  Johannes Korn
Messages: 5
Registered: January 2010
Junior Member
David Fanning wrote:
> Johannes Korn writes:
>
>> Hi,
>>
>> I usually read ascii tables using read_ascii with a ascii template which
>> gives me an anonymous structure with fields of the same length.
>>
>> for example
>> d=READ_ASCII('file', TEMPLATE=templ)
>>
>> afterwards d is d.date, d.time and d.value
>>
>> I would like to "shrink" d to contain only a specific date.
>>
>> Something like
>> ind=where(d.date eq '10052000')
>> d = d[ind]
>>
>> This doesn't work of course but I thought at least d.date = d.date[ind]
>> should. But this doesn't resize d.date but only fills all locations with
>> the values of d.date[ind].
>>
>> Is there any other way than to copy everything to arrays?
>
> How about a shrunken structure? Consider this function:
>
> ;*********************************************************** ************
> Function ShrinkStruct, struct, indices
>
> tags = N_Tags(struct)
> fieldNames = Tag_Names(struct)
>
> newStruct = Create_Struct(fieldNames[0], $
> (struct.(0))[indices])
> FOR j=1,tags-1 DO BEGIN
> newStruct = Create_Struct(newStruct, fieldnames[j], $
> (struct.(j))[indices])
> ENDFOR
>
> RETURN, newStruct
>
> END
> ;*********************************************************** ************

That's what I was looking for. Thanks a lot!

Johannes
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: File Delete -- Friggin A!!
Next Topic: Re: Simultaneous write on textfile over NFS

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

Current Time: Fri Oct 10 10:54:30 PDT 2025

Total time taken to generate the page: 1.36491 seconds