Skip to content

Commit

Permalink
fix rows
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Jun 25, 2020
1 parent 793704e commit 2ae06fe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/rows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# no automatic type inference is done, but types are allowed to be passed
# for as many columns as desired; `CSV.detect(row, i)` can also be used to
# use the same inference logic used in `CSV.File` for determing a cell's typed value
struct Rows{transpose, O, IO, T}
struct Rows{transpose, O, IO, T, F}
name::String
names::Vector{Symbol} # only includes "select"ed columns
finaltypes::Vector{Type} # only includes "select"ed columns
Expand All @@ -22,6 +22,8 @@ struct Rows{transpose, O, IO, T}
positions::Vector{Int64}
reusebuffer::Bool
tapes::Vector{AbstractVector}
filter::F
codes::Vector{Int16}
lookup::Dict{Symbol, Int}
end

Expand Down Expand Up @@ -99,6 +101,7 @@ function Rows(source;
ignoreemptylines::Bool=false,
select=nothing,
drop=nothing,
filter=nothing,
# parsing options
missingstrings=String[],
missingstring="",
Expand Down Expand Up @@ -135,7 +138,8 @@ function Rows(source;
deleteat!(finaltypes, h.todrop)
deleteat!(columnmap, h.todrop)
lookup = Dict(nm=>i for (i, nm) in enumerate(h.names))
return Rows{transpose, typeof(h.options), typeof(h.buf), typeof(h.customtypes)}(
codes = filter === nothing ? EMPTY_CODES : zeros(Int16, h.cols)
return Rows{transpose, typeof(h.options), typeof(h.buf), typeof(h.customtypes), typeof(filter)}(
h.name,
h.names,
finaltypes,
Expand All @@ -155,6 +159,8 @@ function Rows(source;
h.positions,
reusebuffer,
tapes,
filter,
codes,
lookup,
)
end
Expand All @@ -172,7 +178,7 @@ const EMPTY_REFS = RefPool[]
(pos > len || row > r.limit) && return nothing
pos > len && return nothing
tapes = r.reusebuffer ? r.tapes : allocate(1, r.cols, r.types, r.flags)
pos = parserow(1, Val(transpose), r.cols, EMPTY_TYPEMAP, tapes, r.datapos, r.buf, pos, len, r.positions, 0.0, EMPTY_REFS, 1, r.datarow + row - 2, r.types, r.flags, false, r.options, r.coloptions, r.customtypes)
pos = parserow(1, Val(transpose), r.cols, EMPTY_TYPEMAP, tapes, r.datapos, r.buf, pos, len, r.positions, 0.0, EMPTY_REFS, 1, r.datarow + row - 2, r.types, r.flags, r.filter, r.names, r.codes, false, r.options, r.coloptions, r.customtypes)
return Row2(r.names, r.finaltypes, r.columnmap, r.types, r.lookup, tapes, r.buf, r.e, r.options, r.coloptions), (pos, len, row + 1)
end

Expand Down

0 comments on commit 2ae06fe

Please sign in to comment.