Implement SKIP keyword on DATA LIST. Fixes bug #17099.
[pspp] / doc / data-io.texi
index 93f071568f98ac023b80b70ddea9a93fb76c4f45..b5e6ca22450c36308fc42377f8c41284f18bf37f 100644 (file)
@@ -138,9 +138,10 @@ Each form of @cmd{DATA LIST} is described in detail below.
 @display
 DATA LIST [FIXED]
         @{TABLE,NOTABLE@}
 @display
 DATA LIST [FIXED]
         @{TABLE,NOTABLE@}
-        FILE='filename'
-        RECORDS=record_count
-        END=end_var
+        [FILE='file-name']
+        [RECORDS=record_count]
+        [END=end_var]
+        [SKIP=record_count]
         /[line_no] var_spec@dots{}
 
 where each var_spec takes one of the forms
         /[line_no] var_spec@dots{}
 
 where each var_spec takes one of the forms
@@ -153,7 +154,7 @@ positions on each line of single-line or multiline records.  The
 keyword FIXED is optional.
 
 The FILE subcommand must be used if input is to be taken from an
 keyword FIXED is optional.
 
 The FILE subcommand must be used if input is to be taken from an
-external file.  It may be used to specify a filename as a string or a
+external file.  It may be used to specify a file name as a string or a
 file handle (@pxref{File Handles}).  If the FILE subcommand is not used,
 then input is assumed to be specified within the command file using
 @cmd{BEGIN DATA}@dots{}@cmd{END DATA} (@pxref{BEGIN DATA}).
 file handle (@pxref{File Handles}).  If the FILE subcommand is not used,
 then input is assumed to be specified within the command file using
 @cmd{BEGIN DATA}@dots{}@cmd{END DATA} (@pxref{BEGIN DATA}).
@@ -166,6 +167,10 @@ the list of variable specifications later in @cmd{DATA LIST}.
 The END subcommand is only useful in conjunction with @cmd{INPUT
 PROGRAM}.  @xref{INPUT PROGRAM}, for details.
 
 The END subcommand is only useful in conjunction with @cmd{INPUT
 PROGRAM}.  @xref{INPUT PROGRAM}, for details.
 
+The optional SKIP subcommand specifies a number of records to skip at
+the beginning of an input file.  It can be used to skip over a row
+that contains variable names, for example.
+
 @cmd{DATA LIST} can optionally output a table describing how the data file
 will be read.  The TABLE subcommand enables this output, and NOTABLE
 disables it.  The default is to output the table.
 @cmd{DATA LIST} can optionally output a table describing how the data file
 will be read.  The TABLE subcommand enables this output, and NOTABLE
 disables it.  The default is to output the table.
@@ -186,7 +191,7 @@ In columnar style, the starting column and ending column for the field
 are specified after the variable name, separated by a dash (@samp{-}).
 For instance, the third through fifth columns on a line would be
 specified @samp{3-5}.  By default, variables are considered to be in
 are specified after the variable name, separated by a dash (@samp{-}).
 For instance, the third through fifth columns on a line would be
 specified @samp{3-5}.  By default, variables are considered to be in
-@samp{F} format (@pxref{Input/Output Formats}).  (This default can be
+@samp{F} format (@pxref{Input and Output Formats}).  (This default can be
 changed; see @ref{SET} for more information.)
 
 In columnar style, to use a variable format other than the default,
 changed; see @ref{SET} for more information.)
 
 In columnar style, to use a variable format other than the default,
@@ -218,7 +223,7 @@ Implied decimal places also exist in FORTRAN style.  A format
 specification with @var{d} decimal places also has @var{d} implied
 decimal places.
 
 specification with @var{d} decimal places also has @var{d} implied
 decimal places.
 
-In addition to the standard format specifiers (@pxref{Input/Output
+In addition to the standard format specifiers (@pxref{Input and Output
 Formats}), FORTRAN style defines some extensions:
 
 @table @asis
 Formats}), FORTRAN style defines some extensions:
 
 @table @asis
@@ -346,8 +351,9 @@ This example shows keywords abbreviated to their first 3 letters.
 DATA LIST FREE
         [(@{TAB,'c'@}, @dots{})]
         [@{NOTABLE,TABLE@}]
 DATA LIST FREE
         [(@{TAB,'c'@}, @dots{})]
         [@{NOTABLE,TABLE@}]
-        FILE='filename'
-        END=end_var
+        [FILE='file-name']
+        [END=end_var]
+        [SKIP=record_cnt]
         /var_spec@dots{}
 
 where each var_spec takes one of the forms
         /var_spec@dots{}
 
 where each var_spec takes one of the forms
@@ -376,12 +382,12 @@ of quoting is allowed.
 The NOTABLE and TABLE subcommands are as in @cmd{DATA LIST FIXED} above.
 NOTABLE is the default.
 
 The NOTABLE and TABLE subcommands are as in @cmd{DATA LIST FIXED} above.
 NOTABLE is the default.
 
-The FILE and END subcommands are as in @cmd{DATA LIST FIXED} above.
+The FILE, END, and SKIP subcommands are as in @cmd{DATA LIST FIXED} above.
 
 The variables to be parsed are given as a single list of variable names.
 This list must be introduced by a single slash (@samp{/}).  The set of
 variable names may contain format specifications in parentheses
 
 The variables to be parsed are given as a single list of variable names.
 This list must be introduced by a single slash (@samp{/}).  The set of
 variable names may contain format specifications in parentheses
-(@pxref{Input/Output Formats}).  Format specifications apply to all
+(@pxref{Input and Output Formats}).  Format specifications apply to all
 variables back to the previous parenthesized format specification.  
 
 In addition, an asterisk may be used to indicate that all variables
 variables back to the previous parenthesized format specification.  
 
 In addition, an asterisk may be used to indicate that all variables
@@ -398,8 +404,9 @@ on field width apply, but they are honored on output.
 DATA LIST LIST
         [(@{TAB,'c'@}, @dots{})]
         [@{NOTABLE,TABLE@}]
 DATA LIST LIST
         [(@{TAB,'c'@}, @dots{})]
         [@{NOTABLE,TABLE@}]
-        FILE='filename'
-        END=end_var
+        [FILE='file-name']
+        [END=end_var]
+        [SKIP=record_count]
         /var_spec@dots{}
 
 where each var_spec takes one of the forms
         /var_spec@dots{}
 
 where each var_spec takes one of the forms
@@ -442,13 +449,13 @@ the current input program.  @xref{INPUT PROGRAM}.
 @display
 For text files:
         FILE HANDLE handle_name
 @display
 For text files:
         FILE HANDLE handle_name
-                /NAME='filename'
+                /NAME='file-name'
                 [/MODE=CHARACTER]
                 /TABWIDTH=tab_width
 
 For binary files with fixed-length records:
         FILE HANDLE handle_name
                 [/MODE=CHARACTER]
                 /TABWIDTH=tab_width
 
 For binary files with fixed-length records:
         FILE HANDLE handle_name
-                /NAME='filename'
+                /NAME='file-name'
                 /MODE=IMAGE
                 [/LRECL=rec_len]
 
                 /MODE=IMAGE
                 [/LRECL=rec_len]
 
@@ -482,10 +489,11 @@ exception).  By default, each tab is 4 characters wide, but an
 alternate width may be specified on TABWIDTH.  A tab width of 0
 suppresses tab expansion entirely.
 
 alternate width may be specified on TABWIDTH.  A tab width of 0
 suppresses tab expansion entirely.
 
-In IMAGE mode, the data file is opened in ANSI C binary mode and records
-are fixed in length.  In IMAGE mode, LRECL specifies the record length in
-bytes, with a default of 1024.  Tab characters are never expanded to
-spaces in binary mode.
+In IMAGE mode, the data file is opened in ANSI C binary mode.  Record
+length is fixed, with output data truncated or padded with spaces to
+the record length.  LRECL specifies the record length in bytes, with a
+default of 1024.  Tab characters are never expanded to spaces in
+binary mode.  Records
 
 The NAME subcommand specifies the name of the file associated with the
 handle.  It is required in CHARACTER and IMAGE modes.
 
 The NAME subcommand specifies the name of the file associated with the
 handle.  It is required in CHARACTER and IMAGE modes.
@@ -694,7 +702,7 @@ cannot fit on a single line, then a multi-line format will be used.
 @display
 MATRIX DATA
         /VARIABLES=var_list
 @display
 MATRIX DATA
         /VARIABLES=var_list
-        /FILE='filename'
+        /FILE='file-name'
         /FORMAT=@{LIST,FREE@} @{LOWER,UPPER,FULL@} @{DIAGONAL,NODIAGONAL@}
         /SPLIT=@{new_var,var_list@}
         /FACTORS=var_list
         /FORMAT=@{LIST,FREE@} @{LOWER,UPPER,FULL@} @{DIAGONAL,NODIAGONAL@}
         /SPLIT=@{new_var,var_list@}
         /FACTORS=var_list
@@ -805,10 +813,10 @@ NEW FILE.
 
 @display
 PRINT 
 
 @display
 PRINT 
-        OUTFILE='filename'
+        OUTFILE='file-name'
         RECORDS=n_lines
         @{NOTABLE,TABLE@}
         RECORDS=n_lines
         @{NOTABLE,TABLE@}
-        /[line_no] arg@dots{}
+        [/[line_no] arg@dots{}]
 
 arg takes one of the following forms:
         'string' [start-end]
 
 arg takes one of the following forms:
         'string' [start-end]
@@ -817,17 +825,20 @@ arg takes one of the following forms:
         var_list *
 @end display
 
         var_list *
 @end display
 
-The @cmd{PRINT} transformation writes variable data to an output file.
-@cmd{PRINT} is executed when a procedure causes the data to be read.
-Follow @cmd{PRINT} by @cmd{EXECUTE} to print variable data without
-invoking a procedure (@pxref{EXECUTE}).
+The @cmd{PRINT} transformation writes variable data to the listing
+file or an output file.  @cmd{PRINT} is executed when a procedure
+causes the data to be read.  Follow @cmd{PRINT} by @cmd{EXECUTE} to
+print variable data without invoking a procedure (@pxref{EXECUTE}).
 
 
-All @cmd{PRINT} subcommands are optional.
+All @cmd{PRINT} subcommands are optional.  If no strings or variables
+are specified, PRINT outputs a single blank line.
 
 The OUTFILE subcommand specifies the file to receive the output.  The
 file may be a file name as a string or a file handle (@pxref{File
 
 The OUTFILE subcommand specifies the file to receive the output.  The
 file may be a file name as a string or a file handle (@pxref{File
-Handles}).  If OUTFILE is not present then output will be sent to PSPP's
-output listing file.
+Handles}).  If OUTFILE is not present then output will be sent to
+PSPP's output listing file.  When OUTFILE is present, a space is
+inserted at beginning of each output line, even lines that otherwise
+would be blank.
 
 The RECORDS subcommand specifies the number of lines to be output.  The
 number of lines may optionally be surrounded by parentheses.
 
 The RECORDS subcommand specifies the number of lines to be output.  The
 number of lines may optionally be surrounded by parentheses.
@@ -868,7 +879,7 @@ again extend the line to that length.
 
 @display
 PRINT EJECT 
 
 @display
 PRINT EJECT 
-        OUTFILE='filename'
+        OUTFILE='file-name'
         RECORDS=n_lines
         @{NOTABLE,TABLE@}
         /[line_no] arg@dots{}
         RECORDS=n_lines
         @{NOTABLE,TABLE@}
         /[line_no] arg@dots{}
@@ -880,8 +891,20 @@ arg takes one of the following forms:
         var_list *
 @end display
 
         var_list *
 @end display
 
-@cmd{PRINT EJECT} writes data to an output file.  Before the data is
-written, the current page in the listing file is ejected.
+@cmd{PRINT EJECT} advances to the beginning of a new output page in
+the listing file or output file.  It can also output data in the same
+way as @cmd{PRINT}.
+
+All @cmd{PRINT EJECT} subcommands are optional.
+
+Without OUTFILE, PRINT EJECT ejects the current page in
+the listing file, then it produces other output, if any is specified.
+
+With OUTFILE, PRINT EJECT writes its output to the specified file.
+The first line of output is written with @samp{1} inserted in the
+first column.  Commonly, this is the only line of output.  If
+additional lines of output are specified, these additional lines are
+written with a space inserted in the first column, as with PRINT.
 
 @xref{PRINT}, for more information on syntax and usage.
 
 
 @xref{PRINT}, for more information on syntax and usage.
 
@@ -890,7 +913,7 @@ written, the current page in the listing file is ejected.
 @vindex PRINT SPACE
 
 @display
 @vindex PRINT SPACE
 
 @display
-PRINT SPACE OUTFILE='filename' n_lines.
+PRINT SPACE OUTFILE='file-name' n_lines.
 @end display
 
 @cmd{PRINT SPACE} prints one or more blank lines to an output file.
 @end display
 
 @cmd{PRINT SPACE} prints one or more blank lines to an output file.
@@ -940,7 +963,7 @@ file.  Instead, it will re-read the same line multiple times.
 REPEATING DATA
         /STARTS=start-end
         /OCCURS=n_occurs
 REPEATING DATA
         /STARTS=start-end
         /OCCURS=n_occurs
-        /FILE='filename'
+        /FILE='file-name'
         /LENGTH=length
         /CONTINUED[=cont_start-cont_end]
         /ID=id_start-id_end=id_var
         /LENGTH=length
         /CONTINUED[=cont_start-cont_end]
         /ID=id_start-id_end=id_var
@@ -1020,7 +1043,7 @@ structure (@pxref{LOOP}).  Use @cmd{DATA LIST} before, not after,
 
 @display
 WRITE 
 
 @display
 WRITE 
-        OUTFILE='filename'
+        OUTFILE='file-name'
         RECORDS=n_lines
         @{NOTABLE,TABLE@}
         /[line_no] arg@dots{}
         RECORDS=n_lines
         @{NOTABLE,TABLE@}
         /[line_no] arg@dots{}
@@ -1034,11 +1057,29 @@ arg takes one of the following forms:
 
 @code{WRITE} writes text or binary data to an output file.  
 
 
 @code{WRITE} writes text or binary data to an output file.  
 
-@xref{PRINT}, for more information on syntax and usage.  The main
-difference between @code{PRINT} and @code{WRITE} is that @cmd{WRITE}
-uses write formats by default, where PRINT uses print formats.
+@xref{PRINT}, for more information on syntax and usage.  @cmd{PRINT}
+and @cmd{WRITE} differ in only a few ways:
+
+@itemize @bullet
+@item
+@cmd{WRITE} uses write formats by default, whereas @cmd{PRINT} uses
+print formats.
+
+@item
+@cmd{PRINT} inserts a space between variables unless a format is
+explicitly specified, but @cmd{WRITE} never inserts space between
+variables in output.
 
 
-The sole additional difference is that if @cmd{WRITE} is used to send output
-to a binary file, carriage control characters will not be output.
-@xref{FILE HANDLE}, for information on how to declare a file as binary.
+@item
+@cmd{PRINT} inserts a space at the beginning of each line that it
+writes to an output file (and @cmd{PRINT EJECT} inserts @samp{1} at
+the beginning of each line that should begin a new page), but
+@cmd{WRITE} does not.
+
+@item
+@cmd{PRINT} outputs the system-missing value according to its
+specified output format, whereas @cmd{WRITE} outputs the
+system-missing value as a field filled with spaces.  Binary formats
+are an exception.
+@end itemize
 @setfilename ignored
 @setfilename ignored