-
Notifications
You must be signed in to change notification settings - Fork 4
/
b12.fxl
214 lines (172 loc) · 2.79 KB
/
b12.fxl
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Test reading CSV and SSV data.
\try_read=
(\read\in
say_data (read in)
)
\try_read_file=
(\read\name
try_read read (path_under dir_local name)
)
\\test_csv=
(
say "== test_csv"
(
\try=(try_read read_csv_chars)
try []
try
[
" " "-" "1" "1" "." "3" "6" "," "1" "2" CR LF
"2" "1" "," "2" "2" CR LF
"3" "1" "," "3" "2" LF
"4" "1" "," "4" "2" "," "," "," CR
"5" "1" "," "5" "2" LF
CR # blank row
"a" " " "b" "," "c" "d" CR LF
QU "a" "b" " " "c" QU QU "h" "i" QU QU QU ","
QU "3" "." "1" "4" QU
LF
LF # blank row
"6" LF
"3" "3" # no terminating LF
]
try ["x" LF]
# Missing end quote
try [QU]
try [QU "a"]
try ["a" "," QU "b"]
# Embedded quote
try ["a" QU "b"]
try ["a" QU]
# OK
try [QU QU]
try [QU "a" QU]
try ["a" ","]
try ["a" "b" "," "c" ","]
)
(
\try=(try_read read_csv_string)
try
~
12,3,,4
5,6,7
"a b
""hi""
cd","3.14",-48.7
"abc,def""ghi""jklmnopqrstuvwxyz"
~
)
(
\try=(try_read_file read_csv_file)
try "test.csv"
)
)
\\test_tsv=
(
say "== test_tsv"
\try=(try_read read_tsv_string)
try
~
12 3 4
5 6 7
"a b
""hi""
cd" "3.14" -48.7
"abc,def""ghi""jklmnopqrstuvwxyz"
~
)
\\test_ssv=
(
say "== test_ssv"
(
\try=(try_read read_ssv_chars)
try []
try ["a" "b" " " "x" "z" "z" " " "d" " " "e" " " "f" " " CR LF "g" " " "h" "i"]
try ["a" "b" " " "c" " " "q" " " LF "d"]
try [" " " " "a" "b" " " "c" LF CR TAB "x" TAB " " "y" LF LF "z"]
try [" " "a" " " "x" TAB LF " " "b" "c" CR "d" "e" " " "f"]
try [" " "a" "b" "c" "d" ]
try ["a" " " "b" " " "x" "y" " " "z" LF "d" " " "d" ]
try ["a" " " "b" "c" LF LF LF "d" CR LF CR LF]
# Test jamming quoted strings back-to-back, though not recommended.
# a b "c d" ~ e~~ f"gh"~ij ~END k"l"m~1n~ENDo~| p~|q"r"s
# tuv
try
[
"a" "b"
" "
QU "c" " " "d" QU
" "
"~" " " "e" "~"
"~" " " "f" QU "g" QU "h" "~"
"i" "j"
" "
"~" "E" "N" "D" " " "k" QU "l" QU "m" "~" "1" "n" "~" "E" "N" "D"
"o"
"~" "|" " " "p" "~" "|"
"q" QU "r" QU "s"
LF
"t" "u" "v"
]
try ["a" QU "b" QU]
try ["~" "E" "N" "D" " " "a" "~" "E" "N" "D"]
# Test missing terminators.
try ["a" QU "b"]
try ["~"]
try ["~" "E" "N" "D"]
try ["~" "E" "N" "D" " "]
try ["~" "E" "N" "D" " " "a" "~" "E" "N"]
)
(
\try=(try_read read_ssv_string)
try
~TEST
ab xzz d e f
g hi
ab c
x y
z
a x
a b "c d" ~ e~~ f"gh"~ij ~END k"l"m~1n~ENDo~| p~|q"r"s
tuv
"a bb c" ~ x"y"z~ 21 38.3 -44
"aaaa" ~
Block of text here.
Second line.
~ ~END another block
second line~END
1 2 3
~abcde ~a~ab~abc~abcd~abcde
~TEST
# Test some tricky string terminators.
try
~~
~ABC abcd~ABA~ABC x
~ABCD AAB~ABC~ABCD y
~~
)
(
\try=(try_read_file read_ssv_file)
try "test.ssv"
try "missing"
)
)
\\test_xsv=
(
# Test with pipe delimiter.
\try=(try_read (read_xsv_string "|"))
say "== test_xsv"
try
~
12|3||4
5|6|7
"a b
""hi""
cd"|"3.14"|-48.7
"abc|def""ghi""jklmnopqrstuvwxyz"
~
)
show_benchmark;
test_csv
test_tsv
test_ssv
test_xsv