@@ -7,20 +7,20 @@ using Test
7
7
8
8
@testset " CSVFiles" begin
9
9
10
- @testset " basic" begin
11
- array = collect (load (joinpath (@__DIR__ , " data.csv" )))
12
- @test length (array) == 3
13
- @test array == [(Name= " John" ,Age= 34. ,Children= 2 ),(Name= " Sally" ,Age= 54. ,Children= 1 ),(Name= " Jim" ,Age= 23. ,Children= 0 )]
10
+ @testset " basic" begin
11
+ array = collect (load (joinpath (@__DIR__ , " data.csv" )))
12
+ @test length (array) == 3
13
+ @test array == [(Name = " John" , Age = 34. , Children = 2 ),(Name = " Sally" , Age = 54. , Children = 1 ),(Name = " Jim" , Age = 23. , Children = 0 )]
14
14
15
- output_filename = tempname () * " .csv"
15
+ output_filename = tempname () * " .csv"
16
16
17
- try
18
- array |> save (output_filename)
17
+ try
18
+ array |> save (output_filename)
19
19
20
- array2 = collect (load (output_filename))
20
+ array2 = collect (load (output_filename))
21
21
22
- @test array == array2
23
- finally
22
+ @test array == array2
23
+ finally
24
24
GC. gc ()
25
25
rm (output_filename)
26
26
end
35
35
end
36
36
37
37
@testset " missing values" begin
38
- array3 = [(a= DataValue (3 ),b = " df\" e" ),(a= DataValue {Int} (),b = " something" )]
38
+ array3 = [(a = DataValue (3 ), b = " df\" e" ),(a = DataValue {Int} (), b = " something" )]
39
39
40
40
@testset " default" begin
41
41
output_filename2 = tempname () * " .csv"
48
48
end
49
49
50
50
@testset " alternate" begin
51
- output_filename2 = tempname () * " .csv"
51
+ output_filename2 = tempname () * " .csv"
52
52
53
53
try
54
54
array3 |> save (output_filename2, nastring= " " )
62
62
csvf2 = load (joinpath (@__DIR__ , " data.csv" ))
63
63
@test TableTraits. supports_get_columns_copy_using_missing (csvf2) == true
64
64
data = TableTraits. get_columns_copy_using_missing (csvf2)
65
- @test data == (Name= [" John" , " Sally" , " Jim" ], Age= [34. ,54. ,23. ], Children= [2 ,1 ,0 ])
65
+ @test data == (Name = [" John" , " Sally" , " Jim" ], Age = [34. ,54. ,23. ], Children = [2 ,1 ,0 ])
66
66
end
67
67
68
68
@testset " Less Basic" begin
69
- array = [(Name= " John" ,Age= 34. ,Children= 2 ),(Name= " Sally" ,Age= 54. ,Children= 1 ),(Name= " Jim" ,Age= 23. ,Children= 0 )]
69
+ array = [(Name = " John" , Age = 34. , Children = 2 ),(Name = " Sally" , Age = 54. , Children = 1 ),(Name = " Jim" , Age = 23. , Children = 0 )]
70
70
@testset " remote loading" begin
71
71
rem_array = collect (load (" https://raw.githubusercontent.com/queryverse/CSVFiles.jl/v0.2.0/test/data.csv" ))
72
72
@test length (rem_array) == 3
102
102
end
103
103
104
104
@testset " Streams" begin
105
- data = [(Name= " John" ,Age= 34. ,Children= 2 ),(Name= " Sally" ,Age= 54. ,Children= 1 ),(Name= " Jim" ,Age= 23. ,Children= 0 )]
105
+ data = [(Name = " John" , Age = 34. , Children = 2 ),(Name = " Sally" , Age = 54. , Children = 1 ),(Name = " Jim" , Age = 23. , Children = 0 )]
106
106
107
107
@testset " CSV" begin
108
108
stream = IOBuffer ()
121
121
reset (stream)
122
122
csvstream = load (fileiostream)
123
123
reloaded_data2 = TableTraits. get_columns_copy_using_missing (csvstream)
124
- @test reloaded_data2 == (Name= [" John" , " Sally" , " Jim" ], Age= [34. , 54. , 23. ], Children= [2 , 1 , 0 ])
124
+ @test reloaded_data2 == (Name = [" John" , " Sally" , " Jim" ], Age = [34. , 54. , 23. ], Children = [2 , 1 , 0 ])
125
125
end
126
126
127
127
@testset " TSV" begin
@@ -141,12 +141,12 @@ end
141
141
reset (stream)
142
142
csvstream = load (fileiostream)
143
143
reloaded_data2 = TableTraits. get_columns_copy_using_missing (csvstream)
144
- @test reloaded_data2 == (Name= [" John" , " Sally" , " Jim" ], Age= [34. , 54. , 23. ], Children= [2 , 1 , 0 ])
144
+ @test reloaded_data2 == (Name = [" John" , " Sally" , " Jim" ], Age = [34. , 54. , 23. ], Children = [2 , 1 , 0 ])
145
145
end
146
146
end
147
147
148
148
@testset " Compression" begin
149
- data = [(Name= " John" ,Age= 34. ,Children= 2 ),(Name= " Sally" ,Age= 54. ,Children= 1 ),(Name= " Jim" ,Age= 23. ,Children= 0 )]
149
+ data = [(Name = " John" , Age = 34. , Children = 2 ),(Name = " Sally" , Age = 54. , Children = 1 ),(Name = " Jim" , Age = 23. , Children = 0 )]
150
150
151
151
@testset " CSV" begin
152
152
output_filename = " output.csv.gz"
@@ -182,10 +182,10 @@ end
182
182
Sally │ 54.0 │ 1
183
183
Jim │ 23.0 │ 0 """
184
184
185
- @test sprint ((stream,data)-> show (stream, " text/html" , data), x) ==
185
+ @test sprint ((stream, data) -> show (stream, " text/html" , data), x) ==
186
186
" <table><thead><tr><th>Name</th><th>Age</th><th>Children</th></tr></thead><tbody><tr><td>"John"</td><td>34.0</td><td>2</td></tr><tr><td>"Sally"</td><td>54.0</td><td>1</td></tr><tr><td>"Jim"</td><td>23.0</td><td>0</td></tr></tbody></table>"
187
187
188
- @test sprint ((stream,data)-> show (stream, " application/vnd.dataresource+json" , data), x) ==
188
+ @test sprint ((stream, data) -> show (stream, " application/vnd.dataresource+json" , data), x) ==
189
189
" {\" schema\" :{\" fields\" :[{\" name\" :\" Name\" ,\" type\" :\" string\" },{\" name\" :\" Age\" ,\" type\" :\" number\" },{\" name\" :\" Children\" ,\" type\" :\" integer\" }]},\" data\" :[{\" Name\" :\" John\" ,\" Age\" :34.0,\" Children\" :2},{\" Name\" :\" Sally\" ,\" Age\" :54.0,\" Children\" :1},{\" Name\" :\" Jim\" ,\" Age\" :23.0,\" Children\" :0}]}"
190
190
191
191
@test showable (" text/html" , x) == true
@@ -202,10 +202,10 @@ end
202
202
Sally │ 54.0 │ 1
203
203
Jim │ 23.0 │ 0 """
204
204
205
- @test sprint ((stream,data)-> show (stream, " text/html" , data), x2) ==
205
+ @test sprint ((stream, data) -> show (stream, " text/html" , data), x2) ==
206
206
" <table><thead><tr><th>Name</th><th>Age</th><th>Children</th></tr></thead><tbody><tr><td>"John"</td><td>34.0</td><td>2</td></tr><tr><td>"Sally"</td><td>54.0</td><td>1</td></tr><tr><td>"Jim"</td><td>23.0</td><td>0</td></tr></tbody></table>"
207
207
208
- @test sprint ((stream,data)-> show (stream, " application/vnd.dataresource+json" , data), x2) ==
208
+ @test sprint ((stream, data) -> show (stream, " application/vnd.dataresource+json" , data), x2) ==
209
209
" {\" schema\" :{\" fields\" :[{\" name\" :\" Name\" ,\" type\" :\" string\" },{\" name\" :\" Age\" ,\" type\" :\" number\" },{\" name\" :\" Children\" ,\" type\" :\" integer\" }]},\" data\" :[{\" Name\" :\" John\" ,\" Age\" :34.0,\" Children\" :2},{\" Name\" :\" Sally\" ,\" Age\" :54.0,\" Children\" :1},{\" Name\" :\" Jim\" ,\" Age\" :23.0,\" Children\" :0}]}"
210
210
211
211
@test showable (" text/html" , x2) == true
217
217
@testset " savestreaming" begin
218
218
using DataFrames
219
219
220
- df = DataFrame (A = 1 : 2 : 1000 , B = repeat (1 : 10 , inner= 50 ), C = 1 : 500 )
220
+ df = DataFrame (A= 1 : 2 : 1000 , B= repeat (1 : 10 , inner= 50 ), C= 1 : 500 )
221
221
df1 = df[1 : 5 , :]
222
222
df2 = df[6 : 10 , :]
223
223
0 commit comments