4968 Accessing data in the structure returned by READ_ASCII When dealing with ASCII-formatted data files that have large numbers of columns, the best way to access data returned by READ_ASCII is to use the structure tag number indexes. This is recommended over trying to use the READ_ASCII structure's 'FIELDNAME' field, which poses the problems discussed below. The variable returned by READ_ASCII is a structure containing a variable number of fields that have a different naming convention depending upon the number of columns in the target dataset. Unless you explicitly change the names of every one of your columns in your ASCII_TEMPLATE dialog, datasets with less than 9 columns or less will return a READ_ASCII structure with field names ending with one digit, i.e. fields named "FIELD1" through "FIELD9". ASCII data files with 10 - 99 columns of data will return the first 9 column names formatted as "FIELD01" through "FIELD09" (and the remaining columns formatted with 2 digits, e.g. "FIELD99"). Datasets with more than 99 columns returns all FIELDNAMES with 3-digit formatting, so that the first 99 columns are named "FIELD001" through "FIELD099". Therefore, relying on field names is problematical. The answer to this problem is to use structure tags instead. Structure tags can be used to reference a structure in place of structure names. A tag can be referenced using its index enclosed in parentheses as follows: Variable_Name.(Tag_Index) If the variable returned by READ_ASCII is named "mydata", then the first column of values in the dataset will be contained in tag number 0, or mydata.(0). The second column will be contained in tag number 1, or mydata.(1), etc. This is true for any size dataset. To see a demonstration, download the link below by right-clicking and selecting 'Save Target As...' to your current working directory. Then make a completely default 'demo_template' and proceed onto the other commands: IDL> demo_template = ascii_template('sprngfld.txt') IDL> mydata = read_ascii('sprngfld.txt', template=demo_template) IDL> help, /structure, mydata ** Structure , 12 tags, length=1920, refs=1: FIELD01 FLOAT Array[40] FIELD02 FLOAT Array[40] FIELD03 FLOAT Array[40] FIELD04 FLOAT Array[40] FIELD05 FLOAT Array[40] FIELD06 FLOAT Array[40] FIELD07 FLOAT Array[40] FIELD08 FLOAT Array[40] FIELD09 FLOAT Array[40] FIELD10 FLOAT Array[40] FIELD11 FLOAT Array[40] FIELD12 FLOAT Array[40] IDL> print, mydata.(0) 21.2000 27.3000 29.2000 35.4000 14.5000 30.9000 29.0000 27.6000 33.6000 24.4000 31.2000 33.4000 24.4000 30.4000 33.7000 29.3000 31.7000 32.7000 29.7000 27.9000 25.9000 22.0000 28.7000 22.5000 30.0000 24.5000 20.2000 16.9000 30.7000 27.3000 21.9000 29.5000 23.8000 23.4000 17.9000 23.7000 24.4000 29.7000 26.1000 31.1000 Determining 2-D or 3-D locations using the WHERE function Converting Vector Polygons into Individual ROIs in Classic ENVI