Data input and output

<< Click to Display Table of Contents >>

Navigation:  User guide > Data >

Data input and output

If you are using CSV data files you should use the CSVDATA RCP before you name the data files.

CSV data files for processing must be in the same format as portable CSV files produced by the Companion.

The first row is a header row that identifies the columns (variables) and the following rows contain one record each.

The first column should usually be headed "Serial" and contain the serial numbers for each record.  Other columns should contain variable names and will be used to put data into variables with the same name.

If the CSV file is UTF8 encoded and contains non-European text it should include a BOM.  Use Notepad (not WordPad) to add a BOM to a file.

The data contained in the records will depend on the type of variable being defined:

serial

This first column should contain a unique positive integer.

svar

The column must contain a single integer value or be blank.

mvar

The column must contain integer values separated by spaces or be blank.

ivar/jvar

The column must contain a single value, or be blank, or contain the letter U (for undefined).

If the value includes decimal places the value will be rounded when stored.

wvar

The column must contain a single value, or be blank, or contain the letter U (for undefined).

cvar

The column must contain some text or be blank.

The width of the cvar must be defined before attempting to retrieve the text from the data file.

Pick up values

Unless READ statements are used a record will be read at START DATA.

The syntax $* is used to retrieve variable information from columns with the header that matches the variable name.  Data locations are not relevant for CSV data and data widths are not relevant except for cvars.

Here are some simple example definitions of data from a CSV file:

ds $Q1=$*/1-4,

dm $Q2=$*/1,5,7,e,

di $Q3=$*,

dw $Q4=$*,

dc $Q5(20), dc $Q5=$*,