[AIT logo]

Institut für Astronomie und Astrophysik

Abteilung Astronomie

Sand 1, D-72076 Tübingen, Germany
[Uni logo]


READCOL Source code in readcol.pro

READCOL

Name
       READCOL
Purpose
       Read a free-format ASCII file with columns of data into IDL vectors
Explanation
       Lines of data not meeting the specified format (e.g. comments) are
       ignored.  Columns may be separated by commas or spaces.
       Use READFMT to read a fixed-format ASCII file.   Use RDFLOAT for
       much faster I/O (but less flexibility).    Use FORPRINT to write
       columns of data (inverse of READCOL).
Calling Sequence
       READCOL, name, v1, [ v2, v3, v4, v5, ...  v25 , COMMENT=
           DELIMITER= ,FORMAT = , /DEBUG ,  /SILENT , SKIPLINE = , NUMLINE = ]
Input Parameters
       NAME - Name of ASCII data file, scalar string.
Optional Input Keywords
       FORMAT - scalar string containing a letter specifying an IDL type
               for each column of data to be read.  Allowed letters are
               A - string data, B - byte, D - double precision, F- floating
               point, I - integer, L - longword, Z - longword hexadecimal,
               and X - skip a column.
               Columns without a specified format are assumed to be floating
               point.  Examples of valid values of FMT are
       'A,B,I'        ;First column to read as a character string, then
                       1 column of byte data, 1 column integer data
       'L,L,L,L'       ;Four columns will be read as longword arrays.
       ' '             ;All columns are floating point
       If a FORMAT keyword string is not supplied, then all columns are
       assumed to be floating point.
       /SILENT - Normally, READCOL will display each line that it skips over.
               If SILENT is set and non-zero then these messages will be
               suppressed.
       /DEBUG - If this keyword is non-zero, then additional information is
                printed as READCOL attempts to read and interpret the file.
       COMMENT - single character specifying comment signal.   Any line
                beginning with this character will be skipped.   Default is
                no comment lines.
       DELIMITER - single character specifying delimiter used to separate
                columns.   Default is either a comma or a blank.
       SKIPLINE - Scalar specifying number of lines to skip at the top of file
               before reading.   Default is to start at the first line.
       NUMLINE - Scalar specifying number of lines in the file to read.
               Default is to read the entire file
Output Parameters
       V1,V2,V3,...V25 - IDL vectors to contain columns of data.
               Up to 25 columns may be read.  The type of the output vectors
               are as specified by FORMAT.
Example
       Each row in a file position.dat contains a star name and 6 columns
       of data giving an RA and Dec in sexigesimal format.   Read into IDL
       variables.   (NOTE: The star names must not include the delimiter
       as a part of the name, no spaces or commas as default.)
       IDL> FMT = 'A,I,I,F,I,I,F'
       IDL> READCOL,'position.dat',F=FMT,name,hr,min,sec,deg,dmin,dsec
       The HR,MIN,DEG, and DMIN variables will be integer vectors.
       Alternatively, all except the first column could be specified as
       floating point.
       IDL> READCOL,'position.dat',F='A',name,hr,min,sec,deg,dmin,dsec
       To read just the variables HR,MIN,SEC
       IDL> READCOL,'position.dat',F='X,I,I,F',HR,MIN,SEC
Restrictions
       This procedure is designed for generality and not for speed.
       If a large ASCII file is to be read repeatedly, it may be worth
       writing a specialized reader.
       Columns to be read as strings must not contain the delimiter character
       (i.e. commas or spaces by default).   Either change the default
       delimiter with the DELIMITER keyword, or use READFMT to read such files.
       Numeric values are converted to specified format.  For example,
       the value 0.13 read with an 'I' format will be converted to 0.
Procedures Used
       GETTOK(), NUMLINES(), STRNUMBER()
Minimum IDL Version
       V5.3 (Uses STRSPLIT)
Revision History
       Written         W. Landsman                 November, 1988
       Modified             J. Bloch                   June, 1991
       (Fixed problem with over allocation of logical units.)
       Added SKIPLINE and NUMLINE keywords  W. Landsman    March 92
       Read a maximum of 25 cols.  Joan Isensee, Hughes STX Corp., 15-SEP-93.
       Call NUMLINES() function W. Landsman          Feb. 1996
       Added DELIMITER keyword  W. Landsman          Nov. 1999
       Fix indexing typos (i for k) that mysteriously appeared W. L. Mar. 2000
       Hexadecimal support added.  MRG, RITSS, 15 March 2000.
       Default is comma or space delimiters as advertised   W.L. July 2001
       Faster algorithm, use STRSPLIT if V5.3 or later  W.L.  May 2002
       Accept null strings separated by delimiter ,e.g. ',,,'
       Use SCOPE_VARFETCH instead of EXECUTE() for >V6.1  W.L. Jun 2005
       Added compile_opt idl2   W. L.  July 2005

Last modified by pro2html on 2005 July 07 at 03:12 UTC

[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]

Jörn Wilms (wilms@astro.uni-tuebingen.de)
Updated automatically