Skip to content

Commit 0172c61

Browse files
Format files using DocumentFormat
1 parent 55c5f4f commit 0172c61

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

docs/make.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using Documenter, CSVFiles
22

33
makedocs(
4-
modules = [CSVFiles],
5-
sitename = "CSVFiles.jl",
4+
modules=[CSVFiles],
5+
sitename="CSVFiles.jl",
66
analytics="UA-132838790-1",
7-
pages = [
7+
pages=[
88
"Introduction" => "index.md"
99
]
1010
)
1111

1212
deploydocs(
13-
repo = "github.com/queryverse/CSVFiles.jl.git"
13+
repo="github.com/queryverse/CSVFiles.jl.git"
1414
)

src/CSVFiles.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,36 @@ end
5050

5151
Base.showable(::MIME"application/vnd.dataresource+json", source::CSVStream) = true
5252

53-
function fileio_load(f::FileIO.File{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? ',' : deprecated_delim, args...)
54-
if deprecated_delim!==nothing
55-
deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.")
53+
function fileio_load(f::FileIO.File{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? ',' : deprecated_delim, args...)
54+
if deprecated_delim !== nothing
55+
deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.")
5656
Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles)
5757
end
5858

5959
return CSVFile(f.filename, delim, args)
6060
end
6161

62-
function fileio_load(f::FileIO.File{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? '\t' : deprecated_delim, args...)
63-
if deprecated_delim!==nothing
64-
deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.")
62+
function fileio_load(f::FileIO.File{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? '\t' : deprecated_delim, args...)
63+
if deprecated_delim !== nothing
64+
deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.")
6565
Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles)
6666
end
6767

6868
return CSVFile(f.filename, delim, args)
6969
end
7070

71-
function fileio_load(s::FileIO.Stream{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? ',' : deprecated_delim, args...)
72-
if deprecated_delim!==nothing
73-
deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.")
71+
function fileio_load(s::FileIO.Stream{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? ',' : deprecated_delim, args...)
72+
if deprecated_delim !== nothing
73+
deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.")
7474
Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles)
7575
end
7676

7777
return CSVStream(s.io, delim, args)
7878
end
7979

80-
function fileio_load(s::FileIO.Stream{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? '\t' : deprecated_delim, args...)
81-
if deprecated_delim!==nothing
82-
deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.")
80+
function fileio_load(s::FileIO.Stream{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? '\t' : deprecated_delim, args...)
81+
if deprecated_delim !== nothing
82+
deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.")
8383
Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles)
8484
end
8585

@@ -114,7 +114,7 @@ end
114114

115115
function TableTraits.get_columns_copy_using_missing(file::CSVFile)
116116
columns, colnames = _loaddata(file)
117-
return NamedTuple{(Symbol.(colnames)...,), Tuple{typeof.(columns)...}}((columns...,))
117+
return NamedTuple{(Symbol.(colnames)...,),Tuple{typeof.(columns)...}}((columns...,))
118118
end
119119

120120
function IteratorInterfaceExtensions.getiterator(s::CSVStream)
@@ -127,7 +127,7 @@ end
127127

128128
function TableTraits.get_columns_copy_using_missing(s::CSVStream)
129129
columns, colnames = TextParse.csvread(s.io, s.delim; stringarraytype=Array, s.keywords...)
130-
return NamedTuple{(Symbol.(colnames)...,), Tuple{typeof.(columns)...}}((columns...,))
130+
return NamedTuple{(Symbol.(colnames)...,),Tuple{typeof.(columns)...}}((columns...,))
131131
end
132132

133133
function Base.collect(x::CSVFile)

src/csv_writer.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ end
55
function _writevalue(io::IO, value::AbstractString, delim, quotechar, escapechar, nastring)
66
print(io, quotechar)
77
for c in value
8-
if c==quotechar || c==escapechar
8+
if c == quotechar || c == escapechar
99
print(io, escapechar)
1010
end
1111
print(io, c)
@@ -32,8 +32,8 @@ end
3232
push_exprs = Expr(:block)
3333
for i in 1:n
3434
push!(push_exprs.args, :( _writevalue(io, i.$(col_names[i]), delim, quotechar, escapechar, nastring) ))
35-
if i<n
36-
push!(push_exprs.args, :( print(io, delim ) ))
35+
if i < n
36+
push!(push_exprs.args, :( print(io, delim) ))
3737
end
3838
end
3939
push!(push_exprs.args, :( println(io) ))
@@ -52,10 +52,10 @@ function _save(io, data; delim=',', quotechar='"', escapechar='"', nastring="NA"
5252
colnames = collect(eltype(it).parameters[1])
5353

5454
if header
55-
if quotechar===nothing
56-
join(io,[string(colname) for colname in colnames],delim)
55+
if quotechar === nothing
56+
join(io, [string(colname) for colname in colnames], delim)
5757
else
58-
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)
5959
end
6060
println(io)
6161
end
@@ -99,7 +99,7 @@ end
9999
#
100100
# Streaming version writes header (if any) on first call, then appends on subsequent calls.
101101
#
102-
const CSV_or_TSV = Union{FileIO.format"CSV", FileIO.format"TSV"}
102+
const CSV_or_TSV = Union{FileIO.format"CSV",FileIO.format"TSV"}
103103

104104
_delim(T) = T <: FileIO.format"CSV" ? ',' : '\t'
105105

@@ -117,21 +117,21 @@ function fileio_savestreaming(f::FileIO.File{T}, data=nothing; delim=_delim(T),
117117
header=true) where T <: CSV_or_TSV
118118
io = open(f.filename, "w")
119119

120-
if data!==nothing
120+
if data !== nothing
121121
_save(io, data; delim=delim, quotechar=quotechar, escapechar=escapechar, nastring=nastring, header=header)
122122
end
123123

124-
return CSVFileSaveStream(io, data!==nothing, delim, quotechar, escapechar, nastring, header)
124+
return CSVFileSaveStream(io, data !== nothing, delim, quotechar, escapechar, nastring, header)
125125
end
126126

127127
function fileio_savestreaming(s::FileIO.Stream{T}, data=nothing; delim=_delim(T), quotechar='"', escapechar='"', nastring="NA",
128128
header=false) where T <: CSV_or_TSV
129129

130-
if data!==nothing
130+
if data !== nothing
131131
_save(s.io, data; delim=delim, quotechar=quotechar, escapechar=escapechar, nastring=nastring, header=header)
132132
end
133133

134-
return CSVFileSaveStream(s.io, data!==nothing, delim, quotechar, escapechar, nastring, header)
134+
return CSVFileSaveStream(s.io, data !== nothing, delim, quotechar, escapechar, nastring, header)
135135
end
136136

137137
function Base.write(s::CSVFileSaveStream, data)

0 commit comments

Comments
 (0)