@@ -18,18 +18,18 @@ isequaldlm(m1, m2, t) = isequal(m1, m2) && (eltype(m1) == eltype(m2) == t)
1818@test isequaldlm (readdlm (IOBuffer (" 1\t 2\n 3\t 4\n 5\t 6\n " )), [1. 2 ; 3 4 ; 5 6 ], Float64)
1919@test isequaldlm (readdlm (IOBuffer (" 1\t 2\n 3\t 4\n 5\t 6\n " ), Int), [1 2 ; 3 4 ; 5 6 ], Int)
2020
21- @test size (readcsv (IOBuffer (" 1,2,3,4" ))) == (1 ,4 )
22- @test size (readcsv (IOBuffer (" 1,2,3," ))) == (1 ,4 )
23- @test size (readcsv (IOBuffer (" 1,2,3,4\n " ))) == (1 ,4 )
24- @test size (readcsv (IOBuffer (" 1,2,3,\n " ))) == (1 ,4 )
25- @test size (readcsv (IOBuffer (" 1,2,3,4\n 1,2,3,4" ))) == (2 ,4 )
26- @test size (readcsv (IOBuffer (" 1,2,3,4\n 1,2,3," ))) == (2 ,4 )
27- @test size (readcsv (IOBuffer (" 1,2,3,4\n 1,2,3" ))) == (2 ,4 )
28-
29- @test size (readcsv (IOBuffer (" 1,2,3,4\r\n " ))) == (1 ,4 )
30- @test size (readcsv (IOBuffer (" 1,2,3,4\r\n 1,2,3\r\n " ))) == (2 ,4 )
31- @test size (readcsv (IOBuffer (" 1,2,3,4\r\n 1,2,3,4\r\n " ))) == (2 ,4 )
32- @test size (readcsv (IOBuffer (" 1,2,3,\" 4\"\r\n 1,2,3,4\r\n " ))) == (2 ,4 )
21+ @test size (readdlm (IOBuffer (" 1,2,3,4" ), ' , ' )) == (1 ,4 )
22+ @test size (readdlm (IOBuffer (" 1,2,3," ), ' , ' )) == (1 ,4 )
23+ @test size (readdlm (IOBuffer (" 1,2,3,4\n " ), ' , ' )) == (1 ,4 )
24+ @test size (readdlm (IOBuffer (" 1,2,3,\n " ), ' , ' )) == (1 ,4 )
25+ @test size (readdlm (IOBuffer (" 1,2,3,4\n 1,2,3,4" ), ' , ' )) == (2 ,4 )
26+ @test size (readdlm (IOBuffer (" 1,2,3,4\n 1,2,3," ), ' , ' )) == (2 ,4 )
27+ @test size (readdlm (IOBuffer (" 1,2,3,4\n 1,2,3" ), ' , ' )) == (2 ,4 )
28+
29+ @test size (readdlm (IOBuffer (" 1,2,3,4\r\n " ), ' , ' )) == (1 ,4 )
30+ @test size (readdlm (IOBuffer (" 1,2,3,4\r\n 1,2,3\r\n " ), ' , ' )) == (2 ,4 )
31+ @test size (readdlm (IOBuffer (" 1,2,3,4\r\n 1,2,3,4\r\n " ), ' , ' )) == (2 ,4 )
32+ @test size (readdlm (IOBuffer (" 1,2,3,\" 4\"\r\n 1,2,3,4\r\n " ), ' , ' )) == (2 ,4 )
3333
3434@test size (readdlm (IOBuffer (" 1 2 3 4\n 1 2 3" ))) == (2 ,4 )
3535@test size (readdlm (IOBuffer (" 1\t 2 3 4\n 1 2 3" ))) == (2 ,4 )
@@ -73,11 +73,11 @@ let result1 = reshape(Any["t", "c", "", "c"], 2, 2),
7373 @test isequaldlm (readdlm (IOBuffer (" t t \n\"\"\" c\" c" )), result2, Any)
7474end
7575
76- @test isequaldlm (readcsv (IOBuffer (" \n 1,2,3\n 4,5,6\n\n\n " ), skipblanks= false ),
76+ @test isequaldlm (readdlm (IOBuffer (" \n 1,2,3\n 4,5,6\n\n\n " ), ' , ' , skipblanks= false ),
7777 reshape (Any[" " ,1.0 ,4.0 ," " ," " ," " ,2.0 ,5.0 ," " ," " ," " ,3.0 ,6.0 ," " ," " ], 5 , 3 ), Any)
78- @test isequaldlm (readcsv (IOBuffer (" \n 1,2,3\n 4,5,6\n\n\n " ), skipblanks= true ), reshape ([1.0 ,4.0 ,2.0 ,5.0 ,3.0 ,6.0 ], 2 , 3 ), Float64)
79- @test isequaldlm (readcsv (IOBuffer (" 1,2\n\n 4,5" ), skipblanks= false ), reshape (Any[1.0 ," " ,4.0 ,2.0 ," " ,5.0 ], 3 , 2 ), Any)
80- @test isequaldlm (readcsv (IOBuffer (" 1,2\n\n 4,5" ), skipblanks= true ), reshape ([1.0 ,4.0 ,2.0 ,5.0 ], 2 , 2 ), Float64)
78+ @test isequaldlm (readdlm (IOBuffer (" \n 1,2,3\n 4,5,6\n\n\n " ), ' , ' , skipblanks= true ), reshape ([1.0 ,4.0 ,2.0 ,5.0 ,3.0 ,6.0 ], 2 , 3 ), Float64)
79+ @test isequaldlm (readdlm (IOBuffer (" 1,2\n\n 4,5" ), ' , ' , skipblanks= false ), reshape (Any[1.0 ," " ,4.0 ,2.0 ," " ,5.0 ], 3 , 2 ), Any)
80+ @test isequaldlm (readdlm (IOBuffer (" 1,2\n\n 4,5" ), ' , ' , skipblanks= true ), reshape ([1.0 ,4.0 ,2.0 ,5.0 ], 2 , 2 ), Float64)
8181
8282let x = bitrand (5 , 10 ), io = IOBuffer ()
8383 writedlm (io, x)
8888let x = [1 ,2 ,3 ], y = [4 ,5 ,6 ], io = IOBuffer ()
8989 writedlm (io, zip (x,y), " , " )
9090 seek (io, 0 )
91- @test readcsv (io) == [x y]
91+ @test readdlm (io, ' , ' ) == [x y]
9292end
9393
9494let x = [0.1 0.3 0.5 ], io = IOBuffer ()
@@ -100,13 +100,13 @@ end
100100let x = [0.1 0.3 0.5 ], io = IOBuffer ()
101101 writedlm (io, x, " , " )
102102 seek (io, 0 )
103- @test readcsv (io) == [0.1 0.3 0.5 ]
103+ @test readdlm (io, ' , ' ) == [0.1 0.3 0.5 ]
104104end
105105
106106let x = [" abc" , " def\" ghi" , " jk\n l" ], y = [1 , " ," , " \" quoted\" " ], io = IOBuffer ()
107107 writedlm (io, zip (x,y), ' ,' )
108108 seek (io, 0 )
109- @test readcsv (io) == [x y]
109+ @test readdlm (io, ' , ' ) == [x y]
110110end
111111
112112let x = [" a" " b" ; " d" " " ], io = IOBuffer ()
@@ -124,12 +124,12 @@ let x = ["\"hello\"", "world\""], io = IOBuffer()
124124end
125125
126126# test comments
127- @test isequaldlm (readcsv (IOBuffer (" #this is comment\n 1,2,3\n #one more comment\n 4,5,6" )), [1. 2. 3. ;4. 5. 6. ], Float64)
128- @test isequaldlm (readcsv (IOBuffer (" #this is \n #comment\n 1,2,3\n #one more \n #comment\n 4,5,6" )), [1. 2. 3. ;4. 5. 6. ], Float64)
129- @test isequaldlm (readcsv (IOBuffer (" 1,2,#3\n 4,5,6" )), [1. 2. " " ;4. 5. 6. ], Any)
130- @test isequaldlm (readcsv (IOBuffer (" 1#,2,3\n 4,5,6" )), [1. " " " " ;4. 5. 6. ], Any)
131- @test isequaldlm (readcsv (IOBuffer (" 1,2,\" #3\"\n 4,5,6" )), [1. 2. " #3" ;4. 5. 6. ], Any)
132- @test isequaldlm (readcsv (IOBuffer (" 1,2,3\n #with leading whitespace\n 4,5,6" )), [1. 2. 3. ;" " " " " " ;4. 5. 6. ], Any)
127+ @test isequaldlm (readdlm (IOBuffer (" #this is comment\n 1,2,3\n #one more comment\n 4,5,6" ), ' , ' ), [1. 2. 3. ;4. 5. 6. ], Float64)
128+ @test isequaldlm (readdlm (IOBuffer (" #this is \n #comment\n 1,2,3\n #one more \n #comment\n 4,5,6" ), ' , ' ), [1. 2. 3. ;4. 5. 6. ], Float64)
129+ @test isequaldlm (readdlm (IOBuffer (" 1,2,#3\n 4,5,6" ), ' , ' ), [1. 2. " " ;4. 5. 6. ], Any)
130+ @test isequaldlm (readdlm (IOBuffer (" 1#,2,3\n 4,5,6" ), ' , ' ), [1. " " " " ;4. 5. 6. ], Any)
131+ @test isequaldlm (readdlm (IOBuffer (" 1,2,\" #3\"\n 4,5,6" ), ' , ' ), [1. 2. " #3" ;4. 5. 6. ], Any)
132+ @test isequaldlm (readdlm (IOBuffer (" 1,2,3\n #with leading whitespace\n 4,5,6" ), ' , ' ), [1. 2. 3. ;" " " " " " ;4. 5. 6. ], Any)
133133
134134# test skipstart
135135let x = [" a" " b" " c" ; " d" " e" " f" ; " g" " h" " i" ; " A" " B" " C" ; 1 2 3 ; 4 5 6 ; 7 8 9 ], io = IOBuffer ()
@@ -213,21 +213,21 @@ let i18n_data = ["Origin (English)", "Name (English)", "Origin (Native)", "Name
213213 i18n_arr = permutedims (reshape (i18n_data, 4 , Int (floor (length (i18n_data)/ 4 ))), [2 , 1 ])
214214 i18n_buff = PipeBuffer ()
215215 writedlm (i18n_buff, i18n_arr, ' ,' )
216- @test i18n_arr == readcsv (i18n_buff)
216+ @test i18n_arr == readdlm (i18n_buff, ' , ' )
217217
218218 hdr = i18n_arr[1 : 1 , :]
219219 data = i18n_arr[2 : end , :]
220220 writedlm (i18n_buff, i18n_arr, ' ,' )
221- @test (data, hdr) == readcsv (i18n_buff, header= true )
221+ @test (data, hdr) == readdlm (i18n_buff, ' , ' , header= true )
222222
223223 writedlm (i18n_buff, i18n_arr, ' \t ' )
224224 @test (data, hdr) == readdlm (i18n_buff, ' \t ' , header= true )
225225end
226226
227- @test isequaldlm (readcsv (IOBuffer (" 1,22222222222222222222222222222222222222,0x3,10e6\n 2000.1,true,false,-10.34" ), Any),
227+ @test isequaldlm (readdlm (IOBuffer (" 1,22222222222222222222222222222222222222,0x3,10e6\n 2000.1,true,false,-10.34" ), ' , ' , Any),
228228 reshape (Any[1 ,2000.1 ,Float64 (22222222222222222222222222222222222222 ),true ,0x3 ,false ,10e6 ,- 10.34 ], 2 , 4 ), Any)
229229
230- @test isequaldlm (readcsv (IOBuffer (" -9223355253176920979,9223355253176920979" ), Int64), Int64[- 9223355253176920979 9223355253176920979 ], Int64)
230+ @test isequaldlm (readdlm (IOBuffer (" -9223355253176920979,9223355253176920979" ), ' , ' , Int64), Int64[- 9223355253176920979 9223355253176920979 ], Int64)
231231
232232# fix #13028
233233for data in [" A B C" , " A B C\n " ]
@@ -253,13 +253,13 @@ for writefunc in ((io,x) -> show(io, "text/csv", x),
253253 let x = [(1 ,2 ), (3 ,4 )], io = IOBuffer ()
254254 writefunc (io, x)
255255 seek (io, 0 )
256- @test readcsv (io) == [1 2 ; 3 4 ]
256+ @test readdlm (io, ' , ' ) == [1 2 ; 3 4 ]
257257 end
258258 # vectors of strings:
259259 let x = [" foo" , " bar" ], io = IOBuffer ()
260260 writefunc (io, x)
261261 seek (io, 0 )
262- @test vec (readcsv (io)) == x
262+ @test vec (readdlm (io, ' , ' )) == x
263263 end
264264end
265265
@@ -275,12 +275,12 @@ end
275275
276276# issue #21180
277277let data = " \" 721\" ,\" 1438\" ,\" 1439\" ,\" …\" ,\" 1\" "
278- @test readcsv (IOBuffer (data)) == Any[721 1438 1439 " …" 1 ]
278+ @test readdlm (IOBuffer (data), ' , ' ) == Any[721 1438 1439 " …" 1 ]
279279end
280280
281281# issue #21207
282282let data = " \" 1\" ,\" 灣\"\" 灣灣灣灣\" ,\" 3\" "
283- @test readcsv (IOBuffer (data)) == Any[1 " 灣\" 灣灣灣灣" 3 ]
283+ @test readdlm (IOBuffer (data), ' , ' ) == Any[1 " 灣\" 灣灣灣灣" 3 ]
284284end
285285
286286# issue #11484: useful error message for invalid readdlm filepath arguments
0 commit comments