projects
/
pspp-builds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f5574c6
)
Implement SKIP keyword on DATA LIST. Fixes bug #17099.
author
Ben Pfaff
<blp@gnu.org>
Sat, 11 Nov 2006 19:30:59 +0000
(19:30 +0000)
committer
Ben Pfaff
<blp@gnu.org>
Sat, 11 Nov 2006 19:30:59 +0000
(19:30 +0000)
doc/data-io.texi
patch
|
blob
|
history
src/language/data-io/ChangeLog
patch
|
blob
|
history
src/language/data-io/data-list.c
patch
|
blob
|
history
tests/ChangeLog
patch
|
blob
|
history
tests/command/data-list.sh
patch
|
blob
|
history
diff --git
a/doc/data-io.texi
b/doc/data-io.texi
index efff25ea258f266798b6439f8f6ce621973b89e8..b5e6ca22450c36308fc42377f8c41284f18bf37f 100644
(file)
--- a/
doc/data-io.texi
+++ b/
doc/data-io.texi
@@
-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='file-name'
- 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
@@
-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.
@@
-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='file-name'
- 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,7
+382,7
@@
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
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
@@
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='file-name'
- 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
diff --git
a/src/language/data-io/ChangeLog
b/src/language/data-io/ChangeLog
index 2fb050dc4cc2ad6fc95138e7308951dd870da8af..099c4c5e0717e8d77c4a7464bf8067ca5992420c 100644
(file)
--- a/
src/language/data-io/ChangeLog
+++ b/
src/language/data-io/ChangeLog
@@
-1,3
+1,11
@@
+Thu Nov 2 20:56:03 2006 Ben Pfaff <blp@gnu.org>
+
+ 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 <blp@gnu.org>
* placement-parser.c: (PRS_TYPE_T) Now that struct fmt_spec uses
Tue Oct 31 20:04:06 2006 Ben Pfaff <blp@gnu.org>
* placement-parser.c: (PRS_TYPE_T) Now that struct fmt_spec uses
@@
-12,7
+20,6
@@
Tue Oct 31 20:04:06 2006 Ben Pfaff <blp@gnu.org>
(fixed_parse_columns) Ditto.
(fixed_parse_fortran) Ditto.
(fixed_parse_columns) Ditto.
(fixed_parse_fortran) Ditto.
-
Tue Oct 31 18:21:48 2006 Ben Pfaff <blp@gnu.org>
* print-space.c (print_space_trns_proc): Let dfm_put_record add
Tue Oct 31 18:21:48 2006 Ben Pfaff <blp@gnu.org>
* print-space.c (print_space_trns_proc): Let dfm_put_record add
diff --git
a/src/language/data-io/data-list.c
b/src/language/data-io/data-list.c
index a1faffe46a0e6a025566ec04a1e43e0ecd43b01c..136c8e44b7d9970a07e1221c3c199cacdfa2a354 100644
(file)
--- a/
src/language/data-io/data-list.c
+++ b/
src/language/data-io/data-list.c
@@
-99,6
+99,7
@@
struct data_list_pgm
struct variable *end; /* Variable specified on END subcommand. */
int record_cnt; /* Number of records. */
struct string delims; /* Field delimiters. */
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;
};
static const struct case_source_class data_list_source_class;
@@
-134,6
+135,7
@@
cmd_data_list (struct dataset *ds)
dls->type = -1;
dls->end = NULL;
dls->record_cnt = 0;
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);
ds_init_empty (&dls->delims);
ds_register_pool (&dls->delims, dls->pool);
@@
-158,6
+160,14
@@
cmd_data_list (struct dataset *ds)
lex_get ();
lex_match (')');
}
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)
else if (lex_match_id ("END"))
{
if (dls->end)
@@
-819,6
+829,16
@@
data_list_source_read (struct case_source *source,
{
struct data_list_pgm *dls = source->aux;
{
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;
for (;;)
{
bool ok;
diff --git
a/tests/ChangeLog
b/tests/ChangeLog
index 790a3316127138de658c68dc2e59881ea3411829..071cd0121d9a6fb9e51bd00c1627cf90aa4842dd 100644
(file)
--- a/
tests/ChangeLog
+++ b/
tests/ChangeLog
@@
-1,3
+1,8
@@
+Thu Nov 2 20:58:12 2006 Ben Pfaff <blp@gnu.org>
+
+ * command/data-list.sh: Test newly implement SKIP keyword on DATA
+ LIST.
+
Sat Nov 4 16:08:58 2006 Ben Pfaff <blp@gnu.org>
* automake.mk: Add binhex-out.sh, date-out.sh, month-out.sh,
Sat Nov 4 16:08:58 2006 Ben Pfaff <blp@gnu.org>
* automake.mk: Add binhex-out.sh, date-out.sh, month-out.sh,
diff --git
a/tests/command/data-list.sh
b/tests/command/data-list.sh
index fc42b94ca077a78c50b52fca819c010f00153c8c..d16521a102168e9cfc4516b83042e6812dacf0ee 100755
(executable)
--- a/
tests/command/data-list.sh
+++ b/
tests/command/data-list.sh
@@
-64,8
+64,9
@@
end data.
list.
list.
-data list free/A B C D.
+data list free
skip=1
/A B C D.
begin data.
begin data.
+# This record is ignored.
,1,2,3
,4,,5
6
,1,2,3
,4,,5
6
@@
-81,8
+82,10
@@
begin data.
end data.
list.
end data.
list.
-data list free (tab)/A B C D.
+data list free (tab)
skip=2
/A B C D.
begin data.
begin data.
+# These records
+# are skipped.
1 2 3 4
1 2 3
1 2 4
1 2 3 4
1 2 3
1 2 4