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/>.
16 dnl AT_BANNER([DATA LIST])
18 AT_SETUP([DATA LIST LIST with empty fields])
19 AT_DATA([data-list.pspp], [dnl
20 DATA LIST LIST NOTABLE /A B C (F1.0).
34 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
49 AT_SETUP([DATA LIST LIST with explicit delimiters])
50 AT_DATA([data-list.pspp], [dnl
51 data list list ('|','X') /A B C D.
60 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
61 Table: Reading free-form data from INLINE.
68 data-list.pspp:3.9-3.13: warning: Data for variable D is not valid as format F: Number followed by garbage.
72 1.00,23.00,45.00,. @&t@
73 2.00,22.00,34.00,23.00
74 3.00,34.00,34.00,34.00
78 AT_SETUP([DATA LIST FREE with SKIP])
79 AT_DATA([data-list.pspp], [dnl
80 data list free skip=1/A B C D.
82 # This record is ignored.
98 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
99 data-list.pspp:4.6: warning: Data for variable D is not valid as format F: Field contents are not numeric.
112 AT_SETUP([DATA LIST LIST with SKIP and tab delimiter])
113 AT_DATA([data-list.pspp], [dnl
114 data list list (tab) notable skip=2/A B C D.
137 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
141 1.00,2.00,3.00,. @&t@
159 dnl Results of this test were confirmed with SPSS 21:
160 dnl http://lists.gnu.org/archive/html/pspp-dev/2013-09/msg00003.html
161 AT_SETUP([DATA LIST FREE with explicit delimiter at end of line])
162 AT_DATA([data-list.pspp], [dnl
163 DATA LIST FREE(',')/x y z.
171 DATA LIST FREE(',')/x y z.
179 DATA LIST FREE(TAB)/x y z.
187 DATA LIST FREE(TAB)/x y z.
195 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
222 AT_SETUP([DATA LIST FIXED with multiple records per case])
223 AT_DATA([data-list.pspp], [dnl
224 data list fixed notable
225 /1 start 1-20 (adate)
241 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
242 data-list.pspp:8.1-8.3: warning: Data for variable count is not valid as format F: Field contents are not numeric.
244 data-list.pspp:11.1-11.3: warning: Data for variable count is not valid as format F: Field contents are not numeric.
248 07/22/2007,10/06/2007,.
249 07/14/1789,08/26/1789,.
250 01/01/1972,12/31/1999,682
254 AT_SETUP([DATA LIST FIXED with empty trailing record])
255 AT_DATA([data-list.pspp], [dnl
256 data list fixed notable records=2/x 1 y 2.
271 AT_CHECK([pspp -O format=csv data-list.pspp], [0], [dnl
282 dnl Test that PSPP accepts LF and CR LF as line ends, but
283 dnl treats isolated CR as linear whitespace.
284 AT_SETUP([DATA LIST with various line-ends])
285 AT_DATA([data-list.sps], [dnl
286 data list list notable file='input.txt'/a b c.
289 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
290 dnl Make sure that input.txt actually received the data that we expect.
291 dnl It might not have, if we're running on a system that translates \n
292 dnl into some other sequence.
293 AT_CHECK([cksum input.txt], [0], [1732021750 50 input.txt
295 AT_CHECK([pspp -o pspp.csv data-list.sps])
296 AT_CHECK([cat pspp.csv], [0], [dnl
308 AT_SETUP([DATA LIST properly expands tabs in input])
309 AT_DATA([data-list.sps], [dnl
310 data list notable /X 1-50 (a).
312 1 12 123 1234 12345 .
315 print outfile='print.txt' /x.
316 write outfile='write.txt' /x.
319 AT_CHECK([sed -n '/12345/l' data-list.sps], [0], [dnl
320 \t1\t12\t123\t1234\t12345 .$
322 AT_CHECK([pspp -o pspp.csv data-list.sps])
323 dnl The CSV driver drops leading spaces so they don't appear here:
324 AT_CHECK([cat pspp.csv], [0], [dnl
325 1 12 123 1234 12345 . @&t@
327 dnl But they do appear in print.txt. The PRINT command also puts a space
328 dnl at the beginning of the line and after the variable:
329 AT_CHECK([cat print.txt], [0], [dnl
330 1 12 123 1234 12345 . @&t@
332 dnl WRITE doesn't add spaces at the beginning or end of lines:
333 AT_CHECK([cat write.txt], [0], [dnl
334 1 12 123 1234 12345 .
338 AT_SETUP([DATA LIST FREE and LIST report missing delimiters])
339 AT_DATA([data-list.sps], [dnl
340 DATA LIST FREE NOTABLE/s (a10).
346 AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
347 data-list.sps:4: warning: Missing delimiter following quoted string.
356 AT_SETUP([DATA LIST FREE and LIST assume a width if omitted])
357 AT_DATA([data-list.sps], [dnl
358 DATA LIST FREE TABLE/s (a) d (datetime) f (f).
360 AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
361 Table: Reading free-form data from INLINE.
369 AT_SETUP([DATA LIST Decimal comma])
370 AT_DATA([data-list.sps], [dnl
373 DATA LIST NOTABLE LIST /A *.
385 LIST /FORMAT=NUMBERED.
388 AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl
404 AT_SETUP([DATA LIST - Negative SKIP])
405 AT_DATA([data-list.sps], [dnl
406 DATA LIST LIST FILE='f.in' NOTABLE SKIP=-1 /a b c d.
411 AT_CHECK([pspp -O format=csv data-list.sps], [1], [dnl
412 data-list.sps:1: error: DATA LIST: The SKIP value must be nonnegative.
414 data-list.sps:3: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
420 AT_SETUP([DATA LIST - Negative RECORDS])
421 AT_DATA([data-list.sps], [dnl
422 DATA LIST LIST FILE='f.in' NOTABLE RECORDS=-1 /a b c d.
427 AT_CHECK([pspp -O format=csv data-list.sps], [1], [dnl
428 data-list.sps:1: error: DATA LIST: The RECORDS value must be nonnegative.
430 data-list.sps:3: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.