|
Using IDL: Importing and Writing Data into Variables |
|
To import an ASCII file into IDL using a macro, complete the following steps:
ASCII files opened with the Import ASCII macro are stored in structure variables which are named filename_ASCII where filename is the name of the file you opened without the extension.
| Note IDL variables must begin with a letter, and may contain only letters, digits, the underscore character, or the dollar sign. If the first character of filename is not a letter, the prefix "var" is added to the variable name. Any spaces within filename are converted to underscores. Any other illegal characters within filename are removed. |
For example, if you opened ascii.txt, the data is now in the structure variable named ASCII_ASCII. Each field (named in the ASCII Template dialog) is an element of the structure.
The structure can be viewed in the Variable Watch Window.
![]() |
You can specify which part of the structure variable you want to access by using the following syntax:
variable_name.element_name
For example, if you want to view the Longitude field data, enter the following:
Print, ASCII_ASCII.LONGITUDE
If you want to plot the Temperature data, enter the following:
IPLOT, ASCII_ASCII.TEMPERATURE
The following figure results.
IDL Online Help (March 06, 2007)