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([GET DATA /TYPE=TXT])
18 dnl These tests exercise features of GET DATA /TYPE=TXT that
19 dnl it has in common with DATA LIST, using tests drawn from
22 AT_SETUP([GET DATA /TYPE=TXT with explicit delimiters])
23 AT_DATA([get-data.sps], [dnl
24 get data /type=txt /file=inline /delimiters="|X"
25 /variables=A f7.2 B f7.2 C f7.2 D f7.2.
34 AT_CHECK([pspp -o pspp.csv get-data.sps])
35 AT_CHECK([cat pspp.csv], [0], [dnl
39 2.00,22.00,34.00,23.00
40 3.00,34.00,34.00,34.00
44 AT_SETUP([GET DATA /TYPE=TXT with FIRSTCASE])
45 AT_DATA([get-data.sps], [dnl
46 get data /type=txt /file=inline /delimiters=', ' /delcase=variables 4
47 /firstcase=2 /variables=A f7.2 B f7.2 C f7.2 D f7.2.
49 # This record is ignored.
68 AT_CHECK([pspp -o pspp.csv get-data.sps], [0], [ignore])
69 AT_CHECK([cat pspp.csv], [0], [dnl
82 AT_SETUP([GET DATA /TYPE=TXT with FIRSTCASE and tab delimiter])
83 AT_DATA([get-data.sps], [dnl
84 get data /type=txt /file=inline /delimiters='\t' /delcase=variables 4
85 /firstcase=3 /variables=A f7.2 B f7.2 C f7.2 D f7.2.
108 AT_CHECK([pspp -o pspp.csv get-data.sps])
109 AT_CHECK([cat pspp.csv], [0], [dnl
131 AT_SETUP([GET DATA /TYPE=TXT with multiple records per case])
132 AT_DATA([get-data.sps], [dnl
133 get data /type=txt /file=inline /arrangement=fixed /fixcase=3 /variables=
150 AT_CHECK([pspp -o pspp.csv get-data.sps])
151 AT_CHECK([cat pspp.csv], [0], [dnl
154 07/22/07,10/06/2007,321
155 ********,08/26/1789,4
156 01/01/72,12/31/1999,682
160 AT_SETUP([GET DATA /TYPE=TXT with empty trailing record])
161 AT_DATA([get-data.sps], [dnl
162 get data /type=txt /file=inline /arrangement=fixed /fixcase=2 /variables=
179 AT_CHECK([pspp -o pspp.csv get-data.sps])
180 AT_CHECK([cat pspp.csv], [0], [dnl
191 dnl This test is a copy of an example given in the manual
192 dnl in doc/files.texi.
193 AT_SETUP([GET DATA /TYPE=TXT password example])
194 AT_DATA([passwd.data], [dnl
195 root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash
196 blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash
197 john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash
198 jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh
200 AT_DATA([passwd.sps], [dnl
201 GET DATA /TYPE=TXT /FILE='passwd.data' /DELIMITERS=':'
202 /VARIABLES=username A20
211 AT_CHECK([pspp -o pspp.csv passwd.sps])
212 AT_CHECK([cat pspp.csv], [0], [dnl
214 username,password,uid,gid,gecos,home,shell
215 root ,$1$nyeSP5gD$pDq/ ,0,0,",,, ",/root ,/bin/bash @&t@
216 blp ,$1$BrP/pFg4$g7OG ,1000,1000,"Ben Pfaff,,, ",/home/blp ,/bin/bash @&t@
217 john ,$1$JBuq/Fioq$g4A ,1001,1001,"John Darrington,,, ",/home/john ,/bin/bash @&t@
218 jhs ,$1$D3li4hPL$88X1 ,1002,1002,"Jason Stover,,, ",/home/jhs ,/bin/csh @&t@
222 dnl This test is a copy of an example given in the manual
223 dnl in doc/files.texi.
224 AT_SETUP([GET DATA /TYPE=TXT cars example])
225 AT_DATA([cars.data], [dnl
226 model year mileage price type age
227 Civic 2002 29883 15900 Si 2
228 Civic 2003 13415 15900 EX 1
229 Civic 1992 107000 3800 n/a 12
230 Accord 2002 26613 17900 EX 1
232 AT_DATA([cars.sps], [dnl
233 GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2
242 GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2
243 /VARIABLES=model 0-7 A
251 AT_CHECK([pspp -o pspp.csv cars.sps])
252 AT_CHECK([cat pspp.csv], [0], [dnl
254 model,year,mileage,price,type,age
255 Civic ,2002,29883,15900,Si ,2
256 Civic ,2003,13415,15900,EX ,1
257 Civic ,1992,107000,3800,n/a ,12
258 Accord ,2002,26613,17900,EX ,1
261 model,year,mileage,price,type,age
262 Civic ,2002,29883,15900,Si ,2
263 Civic ,2003,13415,15900,EX ,1
264 Civic ,1992,107000,3800,n/a ,12
265 Accord ,2002,26613,17900,EX ,1
269 dnl This test is a copy of an example given in the manual
270 dnl in doc/files.texi.
271 AT_SETUP([GET DATA /TYPE=TXT pets example])
272 AT_DATA([pets.data], [dnl
273 'Pet''s Name', "Age", "Color", "Date Received", "Price", "Height", "Type"
274 , (Years), , , (Dollars), ,
275 "Rover", 4.5, Brown, "12 Feb 2004", 80, '1''4"', "Dog"
276 "Charlie", , Gold, "5 Apr 2007", 12.3, "3""", "Fish"
277 "Molly", 2, Black, "12 Dec 2006", 25, '5"', "Cat"
278 "Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig"
280 AT_DATA([pets.sps], [dnl
281 GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"'
292 AT_CHECK([pspp -o pspp.csv pets.sps])
293 AT_CHECK([cat pspp.csv], [0], [dnl
295 name,age,color,received,price,height,type
296 Rover ,4.5,Brown,12.02.2004,80.00,"1'4"" ",Dog @&t@
297 Charlie ,. ,Gold ,05.04.2007,12.30,"3"" ",Fish @&t@
298 Molly ,2.0,Black,12.12.2006,25.00,"5"" ",Cat @&t@
299 Gilly ,. ,White,10.04.2007,10.00,"3"" ",Guinea Pig
302 dnl " (fixes Emacs highlighting)
304 AT_SETUP([GET DATA /TYPE=TXT with IMPORTCASE])
305 AT_CHECK([$PERL > test.data <<'EOF'
306 for ($i = 1; $i <= 100; $i++) {
311 AT_DATA([get-data.sps], [dnl
312 get data /type=txt /file='test.data' /importcase=first 10 /variables x f8.0.
313 get data /type=txt /file='test.data' /importcase=percent 1 /variables x f8.0.
314 get data /type=txt /file='test.data' /importcase=percent 35 /variables x f8.0.
315 get data /type=txt /file='test.data' /importcase=percent 95 /variables x f8.0.
316 get data /type=txt /file='test.data' /importcase=percent 100 /variables x f8.0.
318 AT_CHECK([pspp -O format=csv get-data.sps], [0], [dnl
319 get-data.sps:1: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
321 get-data.sps:2: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
323 get-data.sps:3: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
325 get-data.sps:4: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
327 get-data.sps:5: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
331 AT_SETUP([GET DATA /TYPE=TXT with ENCODING subcommand])
332 AT_CHECK([i18n-test supports_encodings UTF-8 ISO-8859-1])
333 AT_DATA([get-data.sps], [dnl
335 get data /type=txt /file='data.txt' /encoding='iso-8859-1'
336 /delimiters="," /variables=s a8.
339 printf '\351' > data.txt # é in ISO-8859-1.
340 AT_CHECK([pspp -o pspp.csv get-data.sps])
341 AT_CHECK([cat pspp.csv], [0], [dnl
349 AT_SETUP([GET DATA /TYPE= truncated])
351 AT_DATA([x.sps], [dnl
356 AT_CHECK([pspp -o pspp.csv x.sps], [1], [ignore])
362 AT_SETUP([GET DATA /TYPE=txt bug])
365 AT_DATA([thing.txt], [dnl
372 AT_DATA([x.sps], [dnl
376 /ARRANGEMENT=DELIMITED
387 AT_CHECK([pspp -O format=csv x.sps], [0], [dnl
399 AT_SETUP([GET DATA /TYPE=txt another bug])
401 AT_DATA([crash.sps], [dnl
402 get data /type=txt /file=inline /variables=C f7.2 D f7>2.
410 AT_CHECK([pspp -O format=csv crash.sps], [1], [ignore])