READ_SYLK

The READ_SYLK function reads the contents of a SYLK ( Symbolic Link) format spreadsheet data file and returns the contents of the file, or of a cell data range, in an IDL variable. READ_SYLK returns either a vector of structures or a 2D array containing the spreadsheet cell data.

By default, READ_SYLK returns a vector of structures, each of which contains the data from one row of the table being read. In this case, the individual fields in the structures have the tag names "Col0", "Col1", ..., "Col n ". If the COLMAJOR keyword is specified, each of the structures returned contains data from one column of the table, and the tag names are "Row0", "Row1", ..., "Row n ".

Note: This routine reads only numeric and string SYLK data. It ignores all spreadsheet and cell formatting information (cell width, text justification, font type, date, time, and monetary notations, etc). Note also that the data in a given cell range must be of the same data type (all integers, for example) in order for the read operation to succeed. See the example below for further information.

This routine is written in the IDL language. Its source code can be found in the file read_sylk.pro in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = READ_SYLK( File )

Arguments

File

A scalar string specifying the full path name of the SYLK file to read.

Keywords

ARRAY

Set this keyword to return an IDL array rather than a vector of structures. Note that all the data in the cell range specified must be of the same data type to successfully return an array.

COLMAJOR

Set this keyword to create a vector of structures each containing data from a single column of the table being read. If you are creating an array rather than a vector of structures (the ARRAY keyword is set), setting COLMAJOR has the same effect as transposing the resulting array.

This keyword should be set when importing spreadsheet data which has column major organization (data stored in columns rather than rows).

NCOLS

Set this keyword to the number of spreadsheet columns to read. If not specified, all of the cell columns found in the file are read.

NROWS

Set this keyword to the number of spreadsheet rows to read. If not specified, all of the cell rows found in the file are read.

STARTCOL

Set this keyword to the first column of spreadsheet cells to read. If not specified, the read operation begins with the first column found in the file (column 0).

STARTROW

Set this keyword to the first row of spreadsheet cells to read. If not specified, the read operation begins with the first row of cells found in the file (row 0).

USEDOUBLES

Set this keyword to read any floating-point cell data as double-precision rather than the default single-precision.

USELONGS

Set this keyword to read any integer cell data as long integer type rather than the default integer type.

Examples

Suppose the following spreadsheet table, with the upper left cell (value = "Index") at location (0, 0), has been saved as the SYLK file "file.slk":

Index  Name  Gender  Platform

1      Beth  F       Unix

2      Lubos  M       VMS

3      Louis  M       Windows

4      Thierry  M       Macintosh

Note that the data format of the title row ( string , string , string , string ) is inconsistent with the following four rows ( int , string , string , string ) in the table. Because of this, it is impossible to read all of the table into a single IDL variable. The following two commands, however, will read all of the data:

title = READ_SYLK("file.slk", NROWS = 1)

table = READ_SYLK("file.slk", STARTROW = 1)

PRINT, title ; Display the top row of the table.

IDL prints:

{ Index Name Gender Platform}

PRINT, table

IDL prints:

{1 Beth F Unix}{2 Lubos M VMS}{3 Louis M Windows}{4 Thierry M Macintosh}

To retrieve only the "Name" column:

names = READ_SYLK("file.slk", /ARRAY, STARTROW = 1, $

    STARTCOL = 1, NCOLS = 1)

PRINT, names

IDL prints:

Beth Lubos Louis Thierry

To retrieve the "Name" column in column format:

namescol = READ_SYLK("file.slk", /ARRAY, /COLMAJOR, $

    STARTROW = 1, STARTCOL = 1, NCOLS = 1)

PRINT, namescol

IDL prints:

Beth

Lubos

Louis

Thierry

See Also

WRITE_SYLK