X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Sep 2008 11:07 AM by  anon
Read_Ascii and variable type issue
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 Sep 2008 11:07 AM
    Hi, I need to read a ASCII file with column data as show below: 901    2006/07/04    12:29:25.014385    1152016165014385    48.00816928    -65.28513547    -998.00    33 It's 8 column record with various informations. I got an issue to define the 4th column variable type. The variable type would be define with IDL by an Unsigned Long (0ULL). Or this variable type is not available in the ASCII_TEMPLATE definition. How could I manage this issue.   Thanks in advance. Cheers. Antoine C.

    Deleted User



    New Member


    Posts:
    New Member


    --
    25 Mar 2009 02:50 PM
    ASCII_TEMPLATE needs to be updated to include the ULL and UL and LL data types.  As you've found, they are not an option when using ASCII_TEMPLATE.  However there is a way around this. If you fire up ASCII_TEMPLATE: IDL>template = ascii_template() Then go through the motions and create your template, at first setting the field4 type to 'long', even though you know it won't work.  Then you can alter it programatically once it's been created.  If you examine the structure that is created: IDL> help, template, /struct ** Structure , 10 tags, length=224, data length=221, refs=1:    VERSION         FLOAT           1.00000    DATASTART       LONG                 0    DELIMITER       BYTE        32    MISSINGVALUE    FLOAT               NaN    COMMENTSYMBOL   STRING    ''    FIELDCOUNT      LONG                 8    FIELDTYPES      LONG      Array[8]    FIELDNAMES      STRING    Array[8]    FIELDLOCATIONS  LONG      Array[8]    FIELDGROUPS     LONG      Array[8] you'll see that the template is an IDL structure with the above fields.  You can now change the values in the FIELDTYPES field to whatever you want.  In this case we know that the fourth column should be ULL, so you can do this: IDL> template.fieldtypes[3] = 15 15 is the ULL data type (see the IDL help on the SIZE function for a full list of data type numbers).  Now when you do this: IDL> data = read_ascii('test.txt', template=template) IDL> help, data, /struct ** Structure , 8 tags, length=56, data length=52, refs=1:    FIELD1          LONG      Array[1]    FIELD2          STRING    Array[1]    FIELD3          STRING    Array[1]    FIELD4          ULONG64   Array[1]    FIELD5          FLOAT     Array[1]    FIELD6          FLOAT     Array[1]    FIELD7          FLOAT     Array[1]    FIELD8          LONG      Array[1] IDL> print, data {         901 2006/07/04 12:29:25.014385       1152016165014385       48.0082      -65.2851      -998.000           33 } you can see that now the number is read in correctly.

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 Apr 2009 11:00 AM
    JELLiot, thanks a lot... I just realized that I get an answer on this post. Antoine C.
    You are not authorized to post a reply.