output: Introduce pivot tables.
[pspp] / tests / language / data-io / list.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
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.
8 dnl 
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.
13 dnl 
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
17 AT_BANNER([LIST])
18
19 AT_SETUP([LIST plain cases])
20 AT_DATA([data.txt], [dnl
21    18    1
22    19    7
23    20   26
24    21   76
25    22   57
26    23   58
27    24   38
28    25   38
29    26   30
30    27   21
31    28   23
32 ])
33 AT_DATA([list.sps], [dnl
34 DATA LIST FILE='data.txt'/avar 1-5 bvar 6-10.
35 WEIGHT BY bvar.
36 LIST.
37 ])
38 AT_CHECK([pspp -o pspp.csv list.sps])
39 AT_CHECK([cat pspp.csv], [0], [dnl
40 Table: Reading 1 record from `data.txt'.
41 Variable,Record,Columns,Format
42 avar,1,1-  5,F5.0
43 bvar,1,6- 10,F5.0
44
45 Table: Data List
46 avar,bvar
47 18,1
48 19,7
49 20,26
50 21,76
51 22,57
52 23,58
53 24,38
54 25,38
55 26,30
56 27,21
57 28,23
58 ])
59 AT_CLEANUP
60
61 AT_SETUP([LIST numbered cases])
62 AT_DATA([data.txt], [dnl
63    18    1
64    19    7
65    20   26
66    21   76
67    22   57
68    23   58
69    24   38
70    25   38
71    26   30
72    27   21
73    28   23
74 ])
75 AT_DATA([list.sps], [dnl
76 DATA LIST FILE='data.txt'/avar 1-5 bvar 6-10.
77 WEIGHT BY bvar.
78 LIST/FORMAT NUMBERED.
79 ])
80 AT_CHECK([pspp -o pspp.csv list.sps])
81 AT_CHECK([cat pspp.csv], [0], [dnl
82 Table: Reading 1 record from `data.txt'.
83 Variable,Record,Columns,Format
84 avar,1,1-  5,F5.0
85 bvar,1,6- 10,F5.0
86
87 Table: Data List
88 Case Number,avar,bvar
89 1,18,1
90 2,19,7
91 3,20,26
92 4,21,76
93 5,22,57
94 6,23,58
95 7,24,38
96 8,25,38
97 9,26,30
98 10,27,21
99 11,28,23
100 ])
101 AT_CLEANUP
102
103 # Checks for a crash when LIST did not include the variables from SPLIT
104 # FILE in the same positions (bug #30684).
105 AT_SETUP([LIST with split file])
106 AT_DATA([data.txt], [dnl
107 a 1
108 a 2
109 a 3
110 b 1
111 c 4
112 c 5
113 ])
114 AT_DATA([list.sps], [dnl
115 DATA LIST LIST NOTABLE FILE='data.txt'/s (a1) n.
116 SPLIT FILE BY s.
117 LIST n.
118 ])
119 AT_CHECK([pspp -o pspp.csv list.sps])
120 AT_CHECK([cat pspp.csv], [0], [dnl
121 Table: Split Values
122 Variable,Value
123 s,a
124
125 Table: Data List
126 n
127 1.00
128 2.00
129 3.00
130
131 Table: Split Values
132 Variable,Value
133 s,b
134
135 Table: Data List
136 n
137 1.00
138
139 Table: Split Values
140 Variable,Value
141 s,c
142
143 Table: Data List
144 n
145 4.00
146 5.00
147 ])
148 AT_CLEANUP
149
150 AT_SETUP([LIST lots of variables])
151 AT_DATA([data.txt], [dnl
152 767532466348513789073483106409
153 888693089424177542378334186760
154 492611507909187152726427852242
155 819848892023195875879332001491
156 452777898709563729845541516650
157 239961967077732760663525115073
158 ])
159 AT_DATA([list.sps], [dnl
160 DATA LIST FILE='data.txt' NOTABLE/x01 to x30 1-30.
161 LIST.
162 ])
163 AT_CHECK([pspp -o pspp.csv list.sps])
164 AT_CHECK([cat pspp.csv], [0], [dnl
165 Table: Data List
166 x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30
167 7,6,7,5,3,2,4,6,6,3,4,8,5,1,3,7,8,9,0,7,3,4,8,3,1,0,6,4,0,9
168 8,8,8,6,9,3,0,8,9,4,2,4,1,7,7,5,4,2,3,7,8,3,3,4,1,8,6,7,6,0
169 4,9,2,6,1,1,5,0,7,9,0,9,1,8,7,1,5,2,7,2,6,4,2,7,8,5,2,2,4,2
170 8,1,9,8,4,8,8,9,2,0,2,3,1,9,5,8,7,5,8,7,9,3,3,2,0,0,1,4,9,1
171 4,5,2,7,7,7,8,9,8,7,0,9,5,6,3,7,2,9,8,4,5,5,4,1,5,1,6,6,5,0
172 2,3,9,9,6,1,9,6,7,0,7,7,7,3,2,7,6,0,6,6,3,5,2,5,1,1,5,0,7,3
173 ])
174 AT_CLEANUP
175
176 AT_SETUP([LIST selected cases])
177 AT_DATA([data.txt], [dnl
178 7675324663
179 8886930894
180 4926115079
181 8198488920
182 4527778987
183 2399619670
184 1667799691
185 1623914684
186 3681393233
187 6418731145
188 2284534083
189 6617637452
190 9865713582
191 1163234537
192 9981663637
193 6821567746
194 0952774952
195 1641790193
196 3763182871
197 2046820753
198 7970620091
199 4841176017
200 6949973797
201 1396285996
202 0700489524
203 ])
204 AT_DATA([list.sps], [dnl
205 DATA LIST FILE='data.txt' NOTABLE/x0 to x9 1-10.
206 LIST /CASES=FROM 6 TO 20 BY 5.
207 LIST /CASES=4.
208 LIST /CASES=BY 10.
209 LIST /CASES=FROM 25.
210 LIST /CASES=FROM 26.
211 ])
212 AT_CHECK([pspp -o pspp.csv list.sps])
213 AT_CHECK([cat pspp.csv], [0], [dnl
214 Table: Data List
215 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
216 2,3,9,9,6,1,9,6,7,0
217 2,2,8,4,5,3,4,0,8,3
218 6,8,2,1,5,6,7,7,4,6
219
220 Table: Data List
221 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
222 7,6,7,5,3,2,4,6,6,3
223 8,8,8,6,9,3,0,8,9,4
224 4,9,2,6,1,1,5,0,7,9
225 8,1,9,8,4,8,8,9,2,0
226
227 Table: Data List
228 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
229 7,6,7,5,3,2,4,6,6,3
230 2,2,8,4,5,3,4,0,8,3
231 7,9,7,0,6,2,0,0,9,1
232
233 Table: Data List
234 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
235 0,7,0,0,4,8,9,5,2,4
236
237 Table: Data List
238 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
239 ])
240 AT_CLEANUP
241
242 dnl This program tests for a bug which caused a buffer overflow
243 dnl when the list command attempted to write very long strings.
244 AT_SETUP([LIST very long string])
245 AT_DATA([list.sps], [dnl
246 INPUT PROGRAM.
247 STRING foo (a2000).
248 + COMPUTE foo=CONCAT(RPAD('A',1999, 'x'), 'Z').
249 END CASE.
250 END FILE.
251 END INPUT PROGRAM.
252
253 EXECUTE.
254
255 DISPLAY VARIABLES.
256
257 LIST.
258 ])
259 AT_CHECK([pspp -o pspp.csv list.sps])
260 AT_CHECK([cat pspp.csv], [0], [dnl
261 Table: Variables
262 Name,Position,Print Format,Write Format,Missing Values
263 foo,1,A2000,A2000,
264
265 Table: Data List
266 foo
267 Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZ
268 ])
269 AT_CLEANUP
270
271
272
273 AT_SETUP([LIST crash on invalid input])
274
275 AT_DATA([list.sps], [dnl
276 DATA LIST LIST /`$b.
277 BEGIN DATA.
278 1 3
279 4 6
280 7 9
281 END DATA.
282
283 LIST.
284 ])
285
286 AT_CHECK([pspp -o pspp.csv list.sps], [1], [ignore])
287
288 AT_CLEANUP
289
290 dnl This is an example from doc/tutorial.texi
291 dnl So if the results of this have to be changed in any way,
292 dnl make sure to update that file.
293 AT_SETUP([LIST tutorial example])
294 AT_DATA([list.sps], [dnl
295 data list list /forename (A12) height.
296 begin data.
297 Ahmed 188
298 Bertram 167
299 Catherine 134.231
300 David 109.1
301 end data
302
303 list /format=numbered.
304 ])
305 AT_CHECK([pspp -o pspp.csv -o pspp.txt list.sps])
306 AT_CHECK([cat pspp.csv], [0], [dnl
307 Table: Reading free-form data from INLINE.
308 Variable,Format
309 forename,A12
310 height,F8.0
311
312 Table: Data List
313 Case Number,forename,height
314 1,Ahmed,188.00
315 2,Bertram,167.00
316 3,Catherine,134.23
317 4,David,109.10
318 ])
319 AT_CLEANUP