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