Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


READ_SYLK

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.

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.

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       Windows
2      Lubos  M       UNIX
3      Louis  M       Windows
4      Thierry  M       UNIX

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)
 
;Display the top row of the table.
PRINT, title

IDL prints:

{ Index Name Gender Platform}

Print the table:

PRINT, table

IDL prints:

{1 Beth F Windows}{2 Lubos M UNIX}{3 Louis M Windows}{4 Thierry M UNIX}

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 

Syntax


Result = READ_SYLK( File [, /ARRAY] [, /COLMAJOR] [, NCOLS=columns] [, NROWS=rows] [, STARTCOL=column] [, STARTROW=row] [, /USEDOUBLES] [, /USELONGS] )

Return Value


READ_SYLK returns either a vector of structures or a 2-D 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”, ..., “Coln”. 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”, ..., “Rown”.

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.

Version History


4.0

Introduced

See Also


WRITE_SYLK



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us