Skip to content

Commit 3a6f898

Browse files
authored
Don't abuse some Parsers APIs as much (#1038)
* Don't abuse some Parsers APIs as much * fix * fix 1.6 issue w/ Dict?
1 parent 77578cc commit 3a6f898

6 files changed

Lines changed: 10 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
version:
17-
- '1.3'
17+
- '1.6'
1818
- '1' # automatically expands to the latest stable 1.x release of Julia
1919
- 'nightly'
2020
os:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PooledArrays = "0.5, 1.0"
2626
SentinelArrays = "1.2"
2727
Tables = "1.1"
2828
WeakRefStrings = "1.4"
29-
julia = "1.3"
29+
julia = "1.6"
3030
SnoopPrecompile = "1"
3131

3232
[extras]

src/context.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ end
459459
end
460460

461461
# step 4b: generate or parse column names
462-
names = detectcolumnnames(buf, headerpos, datapos, len, options, header, normalizenames)
462+
names = detectcolumnnames(buf, headerpos, datapos, len, options, header, normalizenames, oq, eq, cq, cmt, ignoreemptyrows)
463463
ncols = length(names)
464464
else
465465
# transpose

src/detection.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function incr!(c::ByteValueCounter, b::UInt8)
161161
end
162162

163163
# given the various header and normalization options, figure out column names for a file
164-
function detectcolumnnames(buf, headerpos, datapos, len, options, @nospecialize(header), normalizenames)::Vector{Symbol}
164+
function detectcolumnnames(buf, headerpos, datapos, len, options, @nospecialize(header), normalizenames, oq, eq, cq, cmt, ignoreemptyrows)::Vector{Symbol}
165165
if header isa Union{AbstractVector{Symbol}, AbstractVector{String}}
166166
fields, pos = readsplitline(buf, datapos, len, options)
167167
isempty(header) && return [Symbol(:Column, i) for i = 1:length(fields)]
@@ -175,7 +175,7 @@ function detectcolumnnames(buf, headerpos, datapos, len, options, @nospecialize(
175175
elseif header isa AbstractVector{<:Integer}
176176
names, pos = readsplitline(buf, headerpos, len, options)
177177
for row = 2:length(header)
178-
pos = skiptorow(buf, pos, len, options.oq, options.e, options.cq, options.cmt, options.ignoreemptylines, 1, header[row] - header[row - 1])
178+
pos = skiptorow(buf, pos, len, oq, eq, cq, cmt, ignoreemptyrows, 1, header[row] - header[row - 1])
179179
fields, pos = readsplitline(buf, pos, len, options)
180180
for (i, x) in enumerate(fields)
181181
names[i] *= "_" * x

src/workload.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const PRECOMPILE_DATA = """"int,float,date,datetime,bool,null,str,catg,int_float
1515

1616
CSV.read(
1717
joinpath(dirname(pathof(CSV)), "..", "test", "testfiles", "precompile_small.csv"),
18-
Dict
18+
Tables.dictcolumntable
1919
)
2020

2121
table = Tables.dictcolumntable(Dict(

src/write.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Base: Ryu
2+
13
"""
24
CSV.write(file, table; kwargs...) => file
35
table |> CSV.write(file; kwargs...) => file
@@ -460,8 +462,8 @@ function writecell(buf, pos, len, io, x::AbstractFloat, opts)
460462
end
461463

462464
function writecell(buf, pos, len, io, x::T, opts) where {T <: Base.IEEEFloat}
463-
@check Parsers.neededdigits(T)
464-
return Parsers.writeshortest(buf, pos, x, false, false, true, -1, UInt8('e'), false, opts.decimal)
465+
@check Ryu.neededdigits(T)
466+
return Ryu.writeshortest(buf, pos, x, false, false, true, -1, UInt8('e'), false, opts.decimal)
465467
end
466468

467469
getvalue(x::T, df) where {T <: Dates.TimeType} = Dates.format(x, df === nothing ? Dates.default_format(T) : df)

0 commit comments

Comments
 (0)