-at_BANNER([GET DATA /TYPE=TXT])
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+dnl AT_BANNER([GET DATA /TYPE=TXT])
dnl These tests exercise features of GET DATA /TYPE=TXT that
dnl it has in common with DATA LIST, using tests drawn from
,4,,5
6
7,
+
8 9
0,1,,,
+
,,,,
+
2
3
end data.
list.
])
-AT_CHECK([pspp -o pspp.csv get-data.sps])
+AT_CHECK([pspp -o pspp.csv get-data.sps], [0], [ignore])
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Data List
A,B,C,D
# These records
# are skipped.
1 2 3 4
-1 2 3 @&t@
+1 2 3 4 @&t@
1 2 4
-1 2 @&t@
+1 2 4 @&t@
1 3 4
-1 3 @&t@
+1 3 4 @&t@
1 4
-1 @&t@
+1 4 @&t@
2 3 4
- 2 3 @&t@
+ 2 3 4 @&t@
2 4
- 2 @&t@
+ 2 4 @&t@
3 4
- 3 @&t@
+ 3 4 @&t@
4
- @&t@
+ 4 @&t@
end data.
list.
])
Table: Data List
A,B,C,D
1.00,2.00,3.00,4.00
-1.00,2.00,3.00,. @&t@
+1.00,2.00,3.00,4.00
+1.00,2.00,. ,4.00
1.00,2.00,. ,4.00
-1.00,2.00,. ,. @&t@
1.00,. ,3.00,4.00
-1.00,. ,3.00,. @&t@
+1.00,. ,3.00,4.00
+1.00,. ,. ,4.00
1.00,. ,. ,4.00
-1.00,. ,. ,. @&t@
. ,2.00,3.00,4.00
-. ,2.00,3.00,. @&t@
+. ,2.00,3.00,4.00
. ,2.00,. ,4.00
-. ,2.00,. ,. @&t@
+. ,2.00,. ,4.00
+. ,. ,3.00,4.00
. ,. ,3.00,4.00
-. ,. ,3.00,. @&t@
. ,. ,. ,4.00
-. ,. ,. ,. @&t@
+. ,. ,. ,4.00
])
AT_CLEANUP
AT_SETUP([GET DATA /TYPE=TXT with multiple records per case])
AT_DATA([get-data.sps], [dnl
get data /type=txt /file=inline /arrangement=fixed /fixcase=3 /variables=
- /1 start 0-19 adate
+ /1 start 0-19 adate8
/2 end 0-19 adate
/3 count 0-2 f.
begin data.
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Data List
start,end,count
-07/22/2007,10/06/2007,321
-07/14/1789,08/26/1789,4
-01/01/1972,12/31/1999,682
+07/22/07,10/06/2007,321
+********,08/26/1789,4
+01/01/72,12/31/1999,682
])
AT_CLEANUP
"Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig"
])
AT_DATA([pets.sps], [dnl
-GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE
+GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"'
/FIRSTCASE=3
/VARIABLES=name A10
age F3.1
AT_CLEANUP
dnl " (fixes Emacs highlighting)
-AT_SETUP([GET DATA /TYPE=TXT with IMPORTCASES])
+AT_SETUP([GET DATA /TYPE=TXT with IMPORTCASE])
AT_CHECK([$PERL > test.data <<'EOF'
for ($i = 1; $i <= 100; $i++) {
printf "%02d\n", $i;
EOF
])
AT_DATA([get-data.sps], [dnl
-get data /type=txt /file='test.data' /importcases=first 10 /variables x f8.0.
-list.
+get data /type=txt /file='test.data' /importcase=first 10 /variables x f8.0.
+get data /type=txt /file='test.data' /importcase=percent 1 /variables x f8.0.
+get data /type=txt /file='test.data' /importcase=percent 35 /variables x f8.0.
+get data /type=txt /file='test.data' /importcase=percent 95 /variables x f8.0.
+get data /type=txt /file='test.data' /importcase=percent 100 /variables x f8.0.
+])
+AT_CHECK([pspp -O format=csv get-data.sps], [0], [dnl
+get-data.sps:1: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
-get data /type=txt /file='test.data' /importcases=percent 1 /variables x f8.0.
-list.
+get-data.sps:2: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
-get data /type=txt /file='test.data' /importcases=percent 35 /variables x f8.0.
-list.
+get-data.sps:3: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
-get data /type=txt /file='test.data' /importcases=percent 95 /variables x f8.0.
-list.
+get-data.sps:4: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
-get data /type=txt /file='test.data' /importcases=percent 100 /variables x f8.0.
+get-data.sps:5: warning: GET DATA: Ignoring obsolete IMPORTCASES subcommand. (N OF CASES or SAMPLE may be used to substitute.)
+])
+AT_CLEANUP
+
+AT_SETUP([GET DATA /TYPE=TXT with ENCODING subcommand])
+AT_CHECK([i18n-test supports_encodings UTF-8 ISO-8859-1])
+AT_DATA([get-data.sps], [dnl
+set locale='utf-8'
+get data /type=txt /file='data.txt' /encoding='iso-8859-1'
+ /delimiters="," /variables=s a8.
list.
])
+printf '\351' > data.txt # é in ISO-8859-1.
AT_CHECK([pspp -o pspp.csv get-data.sps])
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Data List
-x
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
+s
+é @&t@
+])
+AT_CLEANUP
-Table: Data List
-x
-1
-2
-Table: Data List
-x
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
+AT_SETUP([GET DATA /TYPE= truncated])
+
+AT_DATA([x.sps], [dnl
+GET DATA /TYPE=
+.
+])
+
+AT_CHECK([pspp -o pspp.csv x.sps], [1], [ignore])
+
+AT_CLEANUP
+
+
+
+AT_SETUP([GET DATA /TYPE=txt bug])
-Table: Data List
-x
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
+AT_DATA([thing.txt], [dnl
+foo, title, last
+1, this, 1
+2, that, 2
+3, other, 3
+])
+
+AT_DATA([x.sps], [dnl
+GET DATA
+ /TYPE=TXT
+ /FILE="thing.txt"
+ /ARRANGEMENT=DELIMITED
+ /DELCASE=LINE
+ /FIRSTCASE=2
+ /DELIMITERS=","
+ /VARIABLES=foo F1.0
+ title A8
+ last F2.0.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv x.sps], [0], [dnl
Table: Data List
-x
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-99
-100
+foo,title,last
+1,this ,1
+2,that ,2
+3,other ,3
+])
+
+AT_CLEANUP
+
+
+
+AT_SETUP([GET DATA /TYPE=txt another bug])
+
+AT_DATA([crash.sps], [dnl
+get data /type=txt /file=inline /variables=C f7.2 D f7>2.
+begin data.
+3 2
+4 2
+5 2
+end data.
])
+
+AT_CHECK([pspp -O format=csv crash.sps], [1], [ignore])
+
AT_CLEANUP
+
+
+
+
+
+