pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp doc/data-io.texi src/language/data-io/Chan...


From: Ben Pfaff
Subject: [Pspp-cvs] pspp doc/data-io.texi src/language/data-io/Chan...
Date: Sat, 11 Nov 2006 19:30:59 +0000

CVSROOT:        /cvsroot/pspp
Module name:    pspp
Changes by:     Ben Pfaff <blp> 06/11/11 19:30:59

Modified files:
        doc            : data-io.texi 
        src/language/data-io: ChangeLog data-list.c 
        tests          : ChangeLog 
        tests/command  : data-list.sh 

Log message:
        Implement SKIP keyword on DATA LIST.  Fixes bug #17099.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/data-io.texi?cvsroot=pspp&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/ChangeLog?cvsroot=pspp&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/data-io/data-list.c?cvsroot=pspp&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/ChangeLog?cvsroot=pspp&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/command/data-list.sh?cvsroot=pspp&r1=1.10&r2=1.11

Patches:
Index: doc/data-io.texi
===================================================================
RCS file: /cvsroot/pspp/pspp/doc/data-io.texi,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- doc/data-io.texi    5 Nov 2006 05:20:53 -0000       1.10
+++ doc/data-io.texi    11 Nov 2006 19:30:59 -0000      1.11
@@ -138,9 +138,10 @@
 @display
 DATA LIST [FIXED]
         @{TABLE,address@hidden
-        FILE='file-name'
-        RECORDS=record_count
-        END=end_var
+        [FILE='file-name']
+        [RECORDS=record_count]
+        [END=end_var]
+        [SKIP=record_count]
         /[line_no] address@hidden
 
 where each var_spec takes one of the forms
@@ -166,6 +167,10 @@
 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.
@@ -346,8 +351,9 @@
 DATA LIST FREE
         [(@{TAB,'c'@}, @dots{})]
         address@hidden,address@hidden
-        FILE='file-name'
-        END=end_var
+        [FILE='file-name']
+        [END=end_var]
+        [SKIP=record_cnt]
         /address@hidden
 
 where each var_spec takes one of the forms
@@ -376,7 +382,7 @@
 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
@@ -398,8 +404,9 @@
 DATA LIST LIST
         [(@{TAB,'c'@}, @dots{})]
         address@hidden,address@hidden
-        FILE='file-name'
-        END=end_var
+        [FILE='file-name']
+        [END=end_var]
+        [SKIP=record_count]
         /address@hidden
 
 where each var_spec takes one of the forms

Index: src/language/data-io/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/ChangeLog,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- src/language/data-io/ChangeLog      3 Nov 2006 04:53:51 -0000       1.31
+++ src/language/data-io/ChangeLog      11 Nov 2006 19:30:59 -0000      1.32
@@ -1,3 +1,11 @@
+Thu Nov  2 20:56:03 2006  Ben Pfaff  <address@hidden>
+
+       Implement SKIP keyword on DATA LIST.  Fixes bug #17099.
+       
+       * data-list.c: (struct data_list_pgm) Add `skip_records' members.
+       (cmd_data_list) Set skip_records based on user input.
+       (data_list_source_read) Skip records requested by user.
+
 Tue Oct 31 20:04:06 2006  Ben Pfaff  <address@hidden>
 
        * placement-parser.c: (PRS_TYPE_T) Now that struct fmt_spec uses
@@ -12,7 +20,6 @@
        (fixed_parse_columns) Ditto.
        (fixed_parse_fortran) Ditto.
        
-
 Tue Oct 31 18:21:48 2006  Ben Pfaff  <address@hidden>
 
        * print-space.c (print_space_trns_proc): Let dfm_put_record add

Index: src/language/data-io/data-list.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/language/data-io/data-list.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- src/language/data-io/data-list.c    3 Nov 2006 04:53:51 -0000       1.23
+++ src/language/data-io/data-list.c    11 Nov 2006 19:30:59 -0000      1.24
@@ -99,6 +99,7 @@
     struct variable *end;      /* Variable specified on END subcommand. */
     int record_cnt;             /* Number of records. */
     struct string delims;       /* Field delimiters. */
+    int skip_records;           /* Records to skip before first case. */
   };
 
 static const struct case_source_class data_list_source_class;
@@ -134,6 +135,7 @@
   dls->type = -1;
   dls->end = NULL;
   dls->record_cnt = 0;
+  dls->skip_records = 0;
   ds_init_empty (&dls->delims);
   ds_register_pool (&dls->delims, dls->pool);
 
@@ -158,6 +160,14 @@
          lex_get ();
          lex_match (')');
        }
+      else if (lex_match_id ("SKIP"))
+       {
+         lex_match ('=');
+         if (!lex_force_int ())
+           goto error;
+         dls->skip_records = lex_integer ();
+         lex_get ();
+       }
       else if (lex_match_id ("END"))
        {
          if (dls->end)
@@ -819,6 +829,16 @@
 {
   struct data_list_pgm *dls = source->aux;
 
+  /* Skip the requested number of records before reading the
+     first case. */
+  while (dls->skip_records > 0) 
+    {
+      if (dfm_eof (dls->reader))
+        return false;
+      dfm_forward_record (dls->reader);
+      dls->skip_records--;
+    }
+  
   for (;;) 
     {
       bool ok;

Index: tests/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/tests/ChangeLog,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- tests/ChangeLog     5 Nov 2006 05:20:53 -0000       1.64
+++ tests/ChangeLog     11 Nov 2006 19:30:59 -0000      1.65
@@ -1,3 +1,8 @@
+Thu Nov  2 20:58:12 2006  Ben Pfaff  <address@hidden>
+
+       * command/data-list.sh: Test newly implement SKIP keyword on DATA
+       LIST.
+
 Sat Nov  4 16:08:58 2006  Ben Pfaff  <address@hidden>
 
        * automake.mk: Add binhex-out.sh, date-out.sh, month-out.sh,

Index: tests/command/data-list.sh
===================================================================
RCS file: /cvsroot/pspp/pspp/tests/command/data-list.sh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- tests/command/data-list.sh  11 Mar 2006 07:16:40 -0000      1.10
+++ tests/command/data-list.sh  11 Nov 2006 19:30:59 -0000      1.11
@@ -64,8 +64,9 @@
 
 list.
 
-data list free/A B C D.
+data list free skip=1/A B C D.
 begin data.
+# This record is ignored.
 ,1,2,3
 ,4,,5
 6
@@ -81,8 +82,10 @@
 end data.
 list.
 
-data list free (tab)/A B C D.
+data list free (tab) skip=2/A B C D.
 begin data.
+# These records
+# are skipped.
 1      2       3       4
 1      2       3       
 1      2               4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]