Skip to content

Commit 2c400f1

Browse files
authored
Merge pull request #27 from queryverse/julia-0.7
Update to julia 0.7
2 parents fdd0bc6 + dea1f1d commit 2c400f1

File tree

7 files changed

+55
-61
lines changed

7 files changed

+55
-61
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- nightly
89
notifications:
910
email: false
1011
git:

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The CSVFiles.jl package is licensed under the MIT "Expat" License:
22

3-
> Copyright (c) 2017: David Anthoff.
3+
> Copyright (c) 2017-2018: David Anthoff.
44
>
55
>
66
> Permission is hereby granted, free of charge, to any person obtaining a copy

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# CSVFiles.jl v0.9.0
2+
* Drop julia 0.6 support, add julia 0.7 support
3+
14
# CSVFiles.jl v0.8.0
25
* Add nastring option to save
36

REQUIRE

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
julia 0.6
2-
TextParse 0.4.0
3-
IteratorInterfaceExtensions 0.0.2
4-
TableTraits 0.0.3
5-
TableTraitsUtils 0.1.3
6-
DataValues 0.1.0
7-
FileIO 0.9.0
1+
julia 0.7-
2+
TextParse 0.6.0
3+
IteratorInterfaceExtensions 0.1.0
4+
TableTraits 0.3.0
5+
TableTraitsUtils 0.2.0
6+
DataValues 0.4.2
7+
FileIO 1.0.0
88
HTTP 0.6.0
9-
IterableTables 0.6.1
10-
TableShowUtils 0.0.1
9+
IterableTables 0.8.1
10+
TableShowUtils 0.1.0

appveyor.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: latest
5+
6+
platform:
7+
- x86
8+
- x64
59

610
## uncomment the following lines to allow failures on nightly julia
711
## (tests will run but not make your overall status red)
812
#matrix:
913
# allow_failures:
10-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
11-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
14+
# - julia_version: latest
1215

1316
branches:
1417
only:
@@ -22,24 +25,12 @@ notifications:
2225
on_build_status_changed: false
2326

2427
install:
25-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
26-
# If there's a newer build queued for the same PR, cancel this one
27-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
28-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
29-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
30-
throw "There are newer queued builds for this pull request, failing early." }
31-
# Download most recent Julia Windows binary
32-
- ps: (new-object net.webclient).DownloadFile(
33-
$env:JULIA_URL,
34-
"C:\projects\julia-binary.exe")
35-
# Run installer silently, output to C:\projects\julia
36-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
28+
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/master/bin/install.ps1'))
3729

3830
build_script:
39-
# Need to convert from shallow to complete for Pkg.clone to work
40-
- IF EXIST .git\shallow (git fetch --unshallow)
41-
- C:\projects\julia\bin\julia -e "versioninfo();
42-
Pkg.clone(pwd(), \"CSVFiles\"); Pkg.build(\"CSVFiles\")"
31+
- echo "%JL_BUILD_SCRIPT%"
32+
- julia -e "%JL_BUILD_SCRIPT%"
4333

4434
test_script:
45-
- C:\projects\julia\bin\julia -e "Pkg.test(\"CSVFiles\")"
35+
- echo "%JL_TEST_SCRIPT%"
36+
- julia -e "%JL_TEST_SCRIPT%"

src/csv_writer.jl

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1+
function _writevalue(io::IO, value::String, delim, quotechar::Nothing, escapechar, nastring)
2+
print(io, value)
3+
end
4+
15
function _writevalue(io::IO, value::String, delim, quotechar, escapechar, nastring)
2-
if isnull(quotechar)
3-
print(io, value)
4-
else
5-
quotechar_unpacked = get(quotechar)
6-
print(io, quotechar_unpacked)
7-
for c in value
8-
if c==quotechar_unpacked || c==escapechar
9-
print(io, escapechar)
10-
end
11-
print(io, c)
6+
print(io, quotechar)
7+
for c in value
8+
if c==quotechar || c==escapechar
9+
print(io, escapechar)
1210
end
13-
print(io, quotechar_unpacked)
11+
print(io, c)
1412
end
13+
print(io, quotechar)
1514
end
1615

1716
function _writevalue(io::IO, value, delim, quotechar, escapechar, nastring)
1817
print(io, value)
1918
end
2019

21-
function _writevalue{T}(io::IO, value::DataValue{T}, delim, quotechar, escapechar, nastring)
22-
if isnull(value)
20+
function _writevalue(io::IO, value::DataValue{T}, delim, quotechar, escapechar, nastring) where {T}
21+
if isna(value)
2322
print(io, nastring)
2423
else
2524
_writevalue(io, get(value), delim, quotechar, escapechar, nastring)
2625
end
2726
end
2827

2928

30-
@generated function _writecsv{T}(io::IO, it, ::Type{T}, delim, quotechar, escapechar, nastring)
29+
@generated function _writecsv(io::IO, it, ::Type{T}, delim, quotechar, escapechar, nastring) where {T}
3130
col_names = fieldnames(T)
3231
n = length(col_names)
3332
push_exprs = Expr(:block)
@@ -50,19 +49,17 @@ function _save(io, data; delim=',', quotechar='"', escapechar='\\', nastring="NA
5049
isiterabletable(data) || error("Can't write this data to a CSV file.")
5150

5251
it = getiterator(data)
53-
colnames = TableTraits.column_names(it)
54-
55-
quotechar_internal = quotechar==nothing ? Nullable{Char}() : Nullable{Char}(quotechar)
52+
colnames = collect(eltype(it).parameters[1])
5653

5754
if header
58-
if isnull(quotechar_internal)
55+
if quotechar===nothing
5956
join(io,[string(colname) for colname in colnames],delim)
6057
else
61-
join(io,["$(quotechar)" *replace(string(colname), quotechar, "$(escapechar)$(quotechar)") * "$(quotechar)" for colname in colnames],delim)
58+
join(io,["$(quotechar)" * replace(string(colname), quotechar => "$(escapechar)$(quotechar)") * "$(quotechar)" for colname in colnames],delim)
6259
end
6360
println(io)
6461
end
65-
_writecsv(io, it, eltype(it), delim, quotechar_internal, escapechar, nastring)
62+
_writecsv(io, it, eltype(it), delim, quotechar, escapechar, nastring)
6663
end
6764

6865
function _save(filename::AbstractString, data; delim=',', quotechar='"', escapechar='\\', nastring="NA", header=true)

test/runtests.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
using CSVFiles
2-
using NamedTuples
2+
using IteratorInterfaceExtensions
3+
using TableTraits
4+
using FileIO
35
using DataValues
4-
using Base.Test
6+
using Test
57

68
@testset "CSVFiles" begin
79

810
@testset "basic" begin
911
array = collect(load(joinpath(@__DIR__, "data.csv")))
1012
@test length(array) == 3
11-
@test array == [@NT(Name="John",Age=34.,Children=2),@NT(Name="Sally",Age=54.,Children=1),@NT(Name="Jim",Age=23.,Children=0)]
13+
@test array == [(Name="John",Age=34.,Children=2),(Name="Sally",Age=54.,Children=1),(Name="Jim",Age=23.,Children=0)]
1214

1315
output_filename = tempname() * ".csv"
1416

@@ -19,7 +21,7 @@ using Base.Test
1921

2022
@test array == array2
2123
finally
22-
gc()
24+
GC.gc()
2325
rm(output_filename)
2426
end
2527
end
@@ -32,7 +34,7 @@ end
3234
end
3335

3436
@testset "missing values" begin
35-
array3 = [@NT(a=DataValue(3),b="df\"e"),@NT(a=DataValue{Int}(),b="something")]
37+
array3 = [(a=DataValue(3),b="df\"e"),(a=DataValue{Int}(),b="something")]
3638

3739
@testset "default" begin
3840
output_filename2 = tempname() * ".csv"
@@ -56,7 +58,7 @@ end
5658
end
5759

5860
@testset "Less Basic" begin
59-
array = [@NT(Name="John",Age=34.,Children=2),@NT(Name="Sally",Age=54.,Children=1),@NT(Name="Jim",Age=23.,Children=0)]
61+
array = [(Name="John",Age=34.,Children=2),(Name="Sally",Age=54.,Children=1),(Name="Jim",Age=23.,Children=0)]
6062
@testset "remote loading" begin
6163
rem_array = collect(load("https://raw.githubusercontent.com/queryverse/CSVFiles.jl/v0.2.0/test/data.csv"))
6264
@test length(rem_array) == 3
@@ -73,7 +75,7 @@ end
7375
@test length(array4) == 3
7476
@test array4 == array
7577
finally
76-
gc()
78+
GC.gc()
7779
rm(output_filename3)
7880
end
7981
end
@@ -86,14 +88,14 @@ end
8688
array |> save(output_filename4, quotechar=nothing)
8789

8890
finally
89-
gc()
91+
GC.gc()
9092
rm(output_filename4)
9193
end
9294
end
9395
end
9496

9597
@testset "Streams" begin
96-
data = [@NT(Name="John",Age=34.,Children=2),@NT(Name="Sally",Age=54.,Children=1),@NT(Name="Jim",Age=23.,Children=0)]
98+
data = [(Name="John",Age=34.,Children=2),(Name="Sally",Age=54.,Children=1),(Name="Jim",Age=23.,Children=0)]
9799

98100
@testset "CSV" begin
99101
stream = IOBuffer()

0 commit comments

Comments
 (0)