1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([DATA LIST])
19 AT_SETUP([DATA LIST LIST with empty fields])
20 AT_DATA([data-list.pspp], [dnl
21 DATA LIST LIST NOTABLE /A B C (F1.0).
35 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
50 AT_SETUP([DATA LIST LIST with explicit delimiters])
51 AT_DATA([data-list.pspp], [dnl
52 data list list ('|','X') /A B C D.
61 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
62 Table: Reading free-form data from INLINE.
69 data-list.pspp:3.9-3.13: warning: Data for variable D is not valid as format F: Number followed by garbage.
73 1.00,23.00,45.00,. @&t@
74 2.00,22.00,34.00,23.00
75 3.00,34.00,34.00,34.00
79 AT_SETUP([DATA LIST FREE with SKIP])
80 AT_DATA([data-list.pspp], [dnl
81 data list free skip=1/A B C D.
83 # This record is ignored.
99 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
100 data-list.pspp:4.6: warning: Data for variable D is not valid as format F: Field contents are not numeric.
113 AT_SETUP([DATA LIST LIST with SKIP and tab delimiter])
114 AT_DATA([data-list.pspp], [dnl
115 data list list (tab) notable skip=2/A B C D.
138 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
142 1.00,2.00,3.00,. @&t@
160 dnl Results of this test were confirmed with SPSS 21:
161 dnl http://lists.gnu.org/archive/html/pspp-dev/2013-09/msg00003.html
162 AT_SETUP([DATA LIST FREE with explicit delimiter at end of line])
163 AT_DATA([data-list.pspp], [dnl
164 DATA LIST FREE(',')/x y z.
172 DATA LIST FREE(',')/x y z.
180 DATA LIST FREE(TAB)/x y z.
188 DATA LIST FREE(TAB)/x y z.
196 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
223 AT_SETUP([DATA LIST FIXED with multiple records per case])
224 AT_DATA([data-list.pspp], [dnl
225 data list fixed notable
226 /1 start 1-20 (adate)
242 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
243 data-list.pspp:8.1-8.3: warning: Data for variable count is not valid as format F: Field contents are not numeric.
245 data-list.pspp:11.1-11.3: warning: Data for variable count is not valid as format F: Field contents are not numeric.
249 07/22/2007,10/06/2007,.
250 07/14/1789,08/26/1789,.
251 01/01/1972,12/31/1999,682
255 AT_SETUP([DATA LIST FIXED with empty trailing record])
256 AT_DATA([data-list.pspp], [dnl
257 data list fixed notable records=2/x 1 y 2.
272 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
283 dnl Test that PSPP accepts LF and CR LF as line ends, but
284 dnl treats isolated CR as linear whitespace.
285 AT_SETUP([DATA LIST with various line-ends])
286 AT_DATA([data-list.sps], [dnl
287 data list list notable file='input.txt'/a b c.
290 printf '1 2 3\n4 5 6\r\n7\r8\r9\r\n10 11 12\n13 14 15 \r\n16\r\r17\r18\n' > input.txt
291 dnl Make sure that input.txt actually received the data that we expect.
292 dnl It might not have, if we're running on a system that translates \n
293 dnl into some other sequence.
294 AT_CHECK([cksum input.txt], [0], [1732021750 50 input.txt
296 AT_CHECK([pspp -o pspp.csv data-list.sps])
297 AT_CHECK([cat pspp.csv], [0], [dnl
309 AT_SETUP([DATA LIST properly expands tabs in input])
310 AT_DATA([data-list.sps], [dnl
311 data list notable /X 1-50 (a).
313 1 12 123 1234 12345 .
316 print outfile='print.txt' /x.
317 write outfile='write.txt' /x.
320 AT_CHECK([sed -n '/12345/l' data-list.sps], [0], [dnl
321 \t1\t12\t123\t1234\t12345 .$
323 AT_CHECK([pspp -o pspp.csv data-list.sps])
324 dnl The CSV driver drops leading spaces so they don't appear here:
325 AT_CHECK([cat pspp.csv], [0], [dnl
326 1 12 123 1234 12345 . @&t@
328 dnl But they do appear in print.txt. The PRINT command also puts a space
329 dnl at the beginning of the line and after the variable:
330 AT_CHECK([cat print.txt], [0], [dnl
331 1 12 123 1234 12345 . @&t@
333 dnl WRITE doesn't add spaces at the beginning or end of lines:
334 AT_CHECK([cat write.txt], [0], [dnl
335 1 12 123 1234 12345 .
339 AT_SETUP([DATA LIST FREE and LIST report missing delimiters])
340 AT_DATA([data-list.sps], [dnl
341 DATA LIST FREE NOTABLE/s (a10).
347 AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
348 data-list.sps:4: warning: Missing delimiter following quoted string.
357 AT_SETUP([DATA LIST FREE and LIST assume a width if omitted])
358 AT_DATA([data-list.sps], [dnl
359 DATA LIST FREE TABLE/s (a) d (datetime) f (f).
361 AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
362 Table: Reading free-form data from INLINE.
370 AT_SETUP([DATA LIST Decimal comma])
371 AT_DATA([data-list.sps], [dnl
374 DATA LIST NOTABLE LIST /A *.
386 LIST /FORMAT=NUMBERED.
389 AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
404 AT_SETUP([DATA LIST syntax errors])
405 AT_DATA([insert.sps], [dnl
406 INSERT FILE='data-list.sps' ERROR=IGNORE.
408 AT_DATA([data-list.sps], [dnl
410 DATA LIST ENCODING=**.
411 DATA LIST RECORDS=1 RECORDS=2.
416 DATA LIST END=xyzzy END=xyzzy.
425 DATA LIST ENCODING='xyzzy'/x.
427 DATA LIST LIST END=xyzzy/x.
431 DATA LIST FIXED/x 1.5.
432 DATA LIST FIXED/x -1.
433 DATA LIST FIXED/x 5-3.
434 DATA LIST FIXED/x y 1-3.
435 DATA LIST FIXED/x 1-5 (xyzzy).
436 DATA LIST FIXED/x 1-5 (**).
437 DATA LIST FIXED/x 1 (F,5).
438 DATA LIST FIXED/x (2F8.0).
439 DATA LIST FIXED/x **.
440 DATA LIST FIXED/x 1 x 2.
443 DATA LIST FIXED/x 1 (a).
446 DATA LIST FIXED/y 2 (a).
447 DATA LIST FIXED/y 3-4 (a).
449 DATA LIST FIXED RECORDS=1/2 x 1-2.
452 AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl
453 "data-list.sps:1.16-1.17: error: DATA LIST: Syntax error expecting a file name or handle name.
454 1 | DATA LIST FILE=**.
457 "data-list.sps:2.20-2.21: error: DATA LIST: Syntax error expecting string.
458 2 | DATA LIST ENCODING=**.
461 "data-list.sps:3.21-3.27: error: DATA LIST: Subcommand RECORDS may only be specified once.
462 3 | DATA LIST RECORDS=1 RECORDS=2.
465 "data-list.sps:4.20: error: DATA LIST: Syntax error expecting one of the following: FILE, ENCODING, RECORDS, SKIP, END, NOTABLE, TABLE, FIXED, FREE, LIST.
466 4 | DATA LIST RECORDS=0.
469 "data-list.sps:5.16-5.17: error: DATA LIST: Syntax error expecting non-negative integer for SKIP.
470 5 | DATA LIST SKIP=-1.
473 "data-list.sps:6.11-6.13: error: DATA LIST: The END subcommand may only be used within INPUT PROGRAM.
474 6 | DATA LIST END=**.
477 "data-list.sps:8.21-8.23: error: DATA LIST: Subcommand END may only be specified once.
478 8 | DATA LIST END=xyzzy END=xyzzy.
481 "data-list.sps:11.15-11.16: error: DATA LIST: Syntax error expecting identifier.
482 11 | DATA LIST END=**.
485 "data-list.sps:13.11-13.15: error: DATA LIST: Syntax error expecting one of the following: FILE, ENCODING, RECORDS, SKIP, END, NOTABLE, TABLE, FIXED, FREE, LIST.
486 13 | DATA LIST XYZZY.
489 "data-list.sps:14.16-14.19: error: DATA LIST: Only one of FIXED, FREE, or LIST may be specified.
490 14 | DATA LIST FREE LIST.
493 "data-list.sps:15.17-15.18: error: DATA LIST: Syntax error expecting TAB or delimiter string.
494 15 | DATA LIST LIST (**).
497 "data-list.sps:16.11-16.12: error: DATA LIST: Syntax error expecting one of the following: FILE, ENCODING, RECORDS, SKIP, END, NOTABLE, TABLE, FIXED, FREE, LIST.
501 "data-list.sps:17.11-17.26: warning: DATA LIST: Encoding should not be specified for inline data. It will be ignored.
502 17 | DATA LIST ENCODING='xyzzy'/x.
505 "data-list.sps:17.29: error: DATA LIST: SPSS-like or Fortran-like format specification expected after variable names.
506 17 | DATA LIST ENCODING='xyzzy'/x.
509 "data-list.sps:19.16-19.24: error: DATA LIST: The END subcommand may be used only with DATA LIST FIXED.
510 19 | DATA LIST LIST END=xyzzy/x.
513 "data-list.sps:21.17: error: DATA LIST: Syntax error expecting positive integer.
514 21 | DATA LIST FIXED/0.
517 "data-list.sps:22.18-22.19: error: DATA LIST: Syntax error expecting variable name.
518 22 | DATA LIST FIXED/ **.
521 "data-list.sps:23.19-23.21: error: DATA LIST: Syntax error expecting integer.
522 23 | DATA LIST FIXED/x 1.5.
525 "data-list.sps:24.19-24.20: error: DATA LIST: Column positions for fields must be positive.
526 24 | DATA LIST FIXED/x -1.
529 "data-list.sps:25.19-25.21: error: DATA LIST: The ending column for a field must be greater than the starting column.
530 25 | DATA LIST FIXED/x 5-3.
533 "data-list.sps:26.21-26.23: error: DATA LIST: The 3 columns 1-3 can't be evenly divided into 2 fields.
534 26 | DATA LIST FIXED/x y 1-3.
537 "data-list.sps:27.24-27.28: error: DATA LIST: Unknown format type `xyzzy'.
538 27 | DATA LIST FIXED/x 1-5 (xyzzy).
541 "data-list.sps:28.24-28.25: error: DATA LIST: Syntax error expecting `)'.
542 28 | DATA LIST FIXED/x 1-5 (**).
545 "data-list.sps:29.19-29.25: error: DATA LIST: Input format F1.5 specifies 5 decimal places, but width 1 allows at most 1 decimals.
546 29 | DATA LIST FIXED/x 1 (F,5).
549 "data-list.sps:30.20-30.25: error: DATA LIST: Number of variables specified (1) differs from number of variable formats (2).
550 30 | DATA LIST FIXED/x (2F8.0).
553 "data-list.sps:31.19-31.20: error: DATA LIST: SPSS-like or Fortran-like format specification expected after variable names.
554 31 | DATA LIST FIXED/x **.
557 "data-list.sps:32.21: error: DATA LIST: x is a duplicate variable name.
558 32 | DATA LIST FIXED/x 1 x 2.
561 Table: Reading 1 record from INLINE.
562 Variable,Record,Columns,Format
565 "data-list.sps:35.17-35.23: error: DATA LIST: There is already a variable x of a different type.
566 35 | DATA LIST FIXED/x 1 (a).
569 Table: Reading 1 record from INLINE.
570 Variable,Record,Columns,Format
573 "data-list.sps:39.17-39.25: error: DATA LIST: There is already a string variable y of a different width.
574 39 | DATA LIST FIXED/y 3-4 (a).
577 "data-list.sps:41.26-41.29: error: DATA LIST: Cannot place variable x on record 2 when RECORDS=1 is specified.
578 41 | DATA LIST FIXED RECORDS=1/2 x 1-2.