docs
[pspp] / tests / data / format-guesser.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([format guesser])
18
19 AT_SETUP([format guesser])
20 AT_DATA([format-guesser.txt], [dnl
21 # No data.
22 => F8.2
23 "" => F8.2
24 "." => F8.2
25
26 # Numeric formats.
27 "1.2" => F3.1
28 "$1.2" => DOLLAR4.1
29 "1.2%" => PCT4.1
30 "$1.2%" => A5
31 "1e5" => E3.0
32 "1e+5" => E4.0
33 "1+5" => E3.0
34 "1-5" => E3.0
35 "1.2e5" => E5.1
36 "1.3e+5" => E6.1
37 "1.4+5" => E5.1
38 "1e" => A2
39 "1e+" => A3
40 "1+" => A2
41 "1-" => A2
42 "1.5-5" => E5.1
43 "1,123" => COMMA5.0         # Is , is grouping or decimal? Assume grouping.
44 "1.123" => F5.3             # Ditto.
45 "1,12" => F4.2              # Not a group of 3, so last delim must be decimal.
46 "1.12" => F4.2              # Ditto.
47 "1,1234" => F6.4            # Not a group of 3, so last delim must be decimal.
48 "1.1234" => F6.4            # Ditto.
49 "$1.234" => DOLLAR6.3       # Dollar sign means decimal has to be '.'.
50 "$1,234" => DOLLAR6.0       # Ditto.
51 "1.234%" => PCT6.3          # Percent sign means decimal has to be '.'.
52 "1,234%" => PCT6.0          # Ditto.
53 "1,123.456" => COMMA9.3     # Both '.' and ',', so last delim must be decimal.
54 "1.123,456" => DOT9.3       # Ditto.
55 "1,123,456.45" => COMMA12.2 # Ditto.
56 "1.123.456,45" => DOT12.2   # Ditto.
57 "1,123,456" => COMMA9.0     # Ditto.
58 "1.123.456" => DOT9.0       # Ditto.
59
60 # Date and time formats.
61 "01-OCT-1978" => DATE11
62 "01-x-1978" => EDATE9           # Roman numeral for month.
63 "01-13-99" => ADATE8
64 "1-13-99" => ADATE7 (ADATE8)
65 "13-01-99" => EDATE8
66 "13-1-99" => EDATE7 (EDATE8)
67 "32-1-1" => SDATE6 (SDATE8)
68 "1q01" => QYR4
69 "1Q01" => QYR4
70 "1 q 01" => QYR6
71 "1 Q 01" => QYR6
72 "1q2001" => QYR6
73 "1Q2001" => QYR6
74 "1 q 2001" => QYR8
75 "1 Q 2001" => QYR8
76 "oct 05" => MOYR6
77 "oct 2005" => MOYR8
78 "1-1-01 1:2" => A10             # Minute needs at least two digits.
79 "1-1-01 1:02" => DATETIME11.0 (DATETIME17.0)
80 "1-1-01 1:02:3" => A13          # Second needs at least two digits.
81 "1-1-01 1:02:03" => DATETIME20.0
82 "1-1-01 1:02:03.1" => DATETIME20.1 (DATETIME22.1)
83 "1-1-01 +1:02:03.1" => DATETIME20.1 (DATETIME22.1)
84 "1-1-01 -1:02:03.1" => DATETIME20.1 (DATETIME22.1)
85 # XXX YMDHMS formats
86 # XXX MTIME formats
87 "1:30" => TIME4.0 (TIME5.0)
88 "1:30:05" => TIME8.0
89 "-1:30" => TIME5.0
90 "+1:30" => TIME5.0
91 "-1:30:15" => TIME8.0
92 "+1:30:15" => TIME8.0
93 "-1:30:15.5" => TIME10.1
94 "+1:30:15.75" => TIME11.2
95 "1 1:30" => DTIME6.0 (DTIME8.0)
96 "+1 1:30" => DTIME7.0 (DTIME8.0)
97 "-1 1:30" => DTIME7.0 (DTIME8.0)
98 "-1-13-99" => A8
99 "+1-13-99" => A8
100 "1+13+99" => A7
101 "1:00:01.03" => TIME10.2 (TIME11.2)
102 "12 1:00:01.3" => DTIME12.1 (DTIME13.1)
103 "jan" => MONTH3
104 "Feb" => MONTH3
105 "MAR" => MONTH3
106 "i" => A1                       # Not detected as MONTH format.
107 "v" => A1
108 "ix" => A2
109 "x" => A1
110 "january" => MONTH7
111 "janaury" => MONTH7             # Only first three letters are significant.
112 "february" => MONTH8
113 "febraury" => MONTH8
114 "march" => MONTH5
115 "marhc" => MONTH5
116 "april" => MONTH5
117 "may" => MONTH3
118 "june" => MONTH4
119 "july" => MONTH4
120 "august" => MONTH6
121 "september" => MONTH9
122 "october" => MONTH7
123 "november" => MONTH8
124 "decmeber" => MONTH8
125 "december" => MONTH8
126 "monady" => WKDAY6
127 "tuseday" => WKDAY7
128 "wedensday" => WKDAY9
129 "thurdsay" => WKDAY8
130 "fridya" => WKDAY6
131 "saturady" => WKDAY8
132 "sudnay" => WKDAY6
133
134 # Ambiguous; bias in favor of more sensible DD/MM/YY format:
135 "1/1/1978" => EDATE8
136 "01/01/01" => EDATE8
137
138 # Several ambiguous dates can be clarified by one unambiguous example:
139 "1/1/1978" "1/2/1978" "1/3/1978" "1/13/1978" => ADATE9 # MM/DD/YY
140 "01/01/01" "02/01/01" "03/01/01" "13/01/01" => EDATE8  # DD/MM/YY
141 "01/01/01" "02/01/01" "03/01/01" "2013/01/01" => SDATE10 # YY/MM/DD
142 ])
143 AT_CHECK([[(echo "SET DECIMAL=DOT."
144            sed -e 's/#.*//
145 s/[     ]*$//
146 /^$/d
147 s,^\(.*\)=> \(.*\)$,DEBUG FORMAT GUESSER \1.,') \
148            < format-guesser.txt > format-guesser.sps]])
149 AT_CHECK([pspp --testing-mode -O format=csv format-guesser.sps],
150   [0], [], [stderr])
151 AT_CHECK([[sed -e 's/#.*//
152 s/[     ]*$//
153 /^$/d' < format-guesser.txt > expout]])
154 AT_CHECK([cat stderr], [0], [expout])
155 AT_CLEANUP