READ_CSV
Syntax | Return Value | Arguments | Keywords | Version History | See Also
The READ_CSV function reads data from a "comma-separated value" (comma-delimited) text file into an IDL structure variable.
This routine handles CSV files consisting of an optional line of column headers, followed by columnar data, with commas separating each field. Each row is assumed to be a new record. Blank lines at the beginning of the file are automatically ignored.
This routine is written in the IDL language. Its source code can be found in the file read_csv.pro in the lib subdirectory of the IDL distribution.
Syntax
Result = READ_CSV( Filename [, COUNT=variable] [, HEADER=variable] [, MISSING_VALUE=value] [, NUM_RECORDS=value] [, RECORD_START=value] )
Return Value
Returns a structure variable that contains one structure field for each column of data in the CSV file. The data type of the individual structure fields is determined using the following rules:
Arguments
Filename
A string containing the name of a CSV file to be read.
Keywords
COUNT
Set this keyword equal to a named variable that will contain the number of records read.
HEADER
Set this keyword equal to a named variable that will contain the column headers as a vector of strings. If no header exists, an empty scalar string is returned.
Note
The headers will only be returned for CSV files that contain numeric data. If the CSV file contains only string data, the header (if it exists) will be contained in the first data record.
MISSING_VALUE
Set this keyword equal to a value used to replace any missing floating-point or integer data. The default value is 0.
NUM_RECORDS
Set this keyword equal to an integer specifying the number of records to read. By default all records are read.
RECORD_START
Set this keyword equal an integer specifying the index of the first record to read. The default is the first record of the file (record 0).
Version History
See Also
IOPEN, QUERY_ASCII, QUERY_CSV, READ_ASCII, WRITE_CSV