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

Home » Public Forums » archive » defining structure after ascii template
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: defining structure after ascii template [message #85882 is a reply to message #85880] Mon, 16 September 2013 10:24 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
spluque@gmail.com writes:

>
> On Monday, September 16, 2013 11:02:11 AM UTC-5, David Fanning wrote:
>> spluque@gmail.com writes:
>>
>>
>>
>>> As far as I can see, it is not possible to define a structure using a template as the one built via ascii_template(). Essentially, extract a sub-structure from the template returned by ascii_template, containing the column names as tags and the field type. What is the proper way to do this?
>>
>>
>>
>> I honestly have no idea what this question means. Why don't you explain
>>
>> to us what you are trying to do.
>
> Sorry for the terse initial post. Here is what I am trying to do:
>
> 1. I've prepared a template with ascii_template() for reading in an ASCII file via read_ascii().
>
> 2. Before reading the data with read_ascii(), I need to prepare an *array* of structures, where each element is a record (row) in a number of files to be read with the template in (1).
>
> 3. read_ascii() creates a structure that looks like this:
>
> help, data, /structures
> ** Structure <57e3008>, 23 tags, length=7800864, data length=7800864, refs=1:
> FIELD01 LONG Array[84792]
> FIELD02 FLOAT Array[84792]
> FIELD03 LONG Array[84792]
> ...[many more fields]
>
> So the array of structures to be created would like this (abbreviating the number of fields for brevity here):
>
> p={'foo', FIELD01:0L, FIELD02:0.0, FIELD03:0L}
> replicate(p, n_recs)
>
> where n_recs is the total number of records expected.
>
> So the question is how can p be created from the information already there in the template created in (1)?

Well, p *is* the structure you obtained. I guess I don't see the
problem:

IDL> struct = ascii_template()
IDL> help, struct
** Structure <701c24d0>, 10 tags, length=320, data length=313, refs=1:
VERSION FLOAT 1.00000
DATASTART LONG 0
DELIMITER BYTE 32
MISSINGVALUE FLOAT NaN
COMMENTSYMBOL STRING ''
FIELDCOUNT LONG 10
FIELDTYPES LONG Array[10]
FIELDNAMES STRING Array[10]
FIELDLOCATIONS LONG Array[10]
FIELDGROUPS LONG Array[10]
IDL> data = Replicate(struct, 100)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merits of different ways of 'extending' arrays
Next Topic: Import data in IDL from other source

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

Current Time: Wed Oct 08 19:27:07 PDT 2025

Total time taken to generate the page: 0.00473 seconds