What is a File Reader?

Simply put, a file reader is an IDL routine that can open a file of a specified file type, read the data from that file, and create one or more IDL variables containing the data. IDL includes a set of Default File Readers; you can also create custom file readers to read data from files in less common formats.

Tip
See the documentation for READ_IMAGE or any of the other READ_* routines for additional information about file reader routines. Many of the READ_* routines are written in the IDL language; you can inspect their source code for ideas on how to create a file reader for files of other data formats.

Using File Readers

File readers are used in the following ways:

A registered file type is identified in IDL's file reader registry file as having a reader routine capable of reading data in its file format. The file reader registry is described in detail in Registering Custom File Readers. Many common file types are registered by default; see Default File Readers, below.

Default File Readers

Table 9-1 lists the file types for which IDL supplies a default file reader routine. If the table contains the word "Yes" in the Registered column, IDL will attempt to use the file reader routine shown if you select a file with the listed file extension using either the File Open menu item in the IDL Workbench or the IOPEN routine.

Note
If the selected file does not have one of the extensions shown in Table 9-1, IDL will attempt to locate a suitable file reader. See File Reader Search Algorithm for details.

Table 9-1: IDL's Default File Readers 

File Type
File Extensions
Reader Routine
Registered

ASCII text

.txt

READ_ASCII

Yes

Binary data

various

READ_BINARY

Yes (using IOPEN only)

Bitmap image

.bmp

READ_BMP

Yes

Comma-separated values (text)

.csv

READ_CSV

Yes

DICOM image

.dcm

READ_DICOM

Yes

GIF image

.gif

READ_GIF

Yes

Interfile image

.hdr, various

READ_INTERFILE

No

JPEG image

.jpg, .jpeg

READ_JPEG

Yes

JPEG2000 image

.jp2, .j2k,.jpx

READ_JPEG2000

Yes

MrSID image

.sid

READ_MRSID

No

Macintosh PICT image

.pict

READ_PICT

Yes

PNG image

.png

READ_PNG

Yes

PPM image

.ppm

READ_PPM

No

Shapefile

.shp

IDLffShape

Yes

Sun Rasterfile image

.srf

READ_SRF

No

Symbolic Link spreadsheet data

.slk

READ_SYLK

No

TIFF image

.tif, .tiff

READ_TIFF

Yes

Audio Stream data

.wav

READ_WAV

Yes

Wavefront Data Visualizer data

.wave

READ_WAVE

No

X11 Bitmap image

various

READ_X11_BITMAP

No

X Windows Dump image

various

READ_XWD

No

Creating a Custom File Reader

If you have data contained in files that do not match any of the file types listed in Table 9-1, you may want to create and register a custom file reader. To create a file reader:

  1. Use IDL's file input/output routines to create a routine that can open your data files and read the contents. See Files and Input/Output in the Application Programming manual for information on IDL's input/output capabilities.
  2. If you only want to use your file reader from the IDL command line or in IDL programs, there are no restrictions on the reader routine. If you want to register your file reader with IDL so that it will be used by the IOPEN routine and when selecting files using the IDL Workbench File Open menu item, be sure to create the reader routine as described in Creating a Registered File Reader Routine.

  3. If you want to register your file reader, consider creating a query routine as described in Creating a Registered Query Routine. The query routine is optional, but allows IDL to determine if a file with an unknown file extension should be opened using your file reader.
  4. If you want to register your file reader, update the idlextenions.xml file as described in Registering Custom File Readers.