-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing error when setting column type to ZonedDateTime #807
Comments
The cause of the exception seems to be this: default(::Type{T}) where {T <: Dates.TimeType} = T(0) Since the constructor for Still not sure why it's actually getting there. |
I can get around the initial issue by extending using CSV, Dates, TimeZones, DataFrames, Parsers
import Parsers.default
default(::Type{ZonedDateTime}) = ZonedDateTime(DateTime(0), TimeZones.utc_tz) This then gives me the following error when I try to parse: df_tz = CSV.File("/data/testdb/test-types.csv", types=Dict(:d => ZonedDateTime)) |> DataFrame
ERROR: TypeError: in typeassert, expected Tuple{Char,Int64}, got a value of type Tuple{UInt8,Int64}
Stacktrace:
[1] tryparsenext_fixedtz(::Array{UInt8,1}, ::Int64, ::Int64, ::Int64, ::Int64) at /home/ubuntu/.julia/packages/TimeZones/K98G0/src/parse.jl:12
[2] tryparsenext at /home/ubuntu/.julia/packages/TimeZones/K98G0/src/parse.jl:69 [inlined]
[3] tryparsenext at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Dates/src/io.jl:41 [inlined]
[4] macro expansion at /home/ubuntu/.julia/packages/Parsers/2MBHI/src/dates.jl:84 [inlined]
[5] mytryparsenext_core at /home/ubuntu/.julia/packages/Parsers/2MBHI/src/dates.jl:61 [inlined]
[6] macro expansion at /home/ubuntu/.julia/packages/Parsers/2MBHI/src/dates.jl:52 [inlined]
[7] mytryparsenext_internal at /home/ubuntu/.julia/packages/Parsers/2MBHI/src/dates.jl:32 [inlined]
[8] typeparser at /home/ubuntu/.julia/packages/Parsers/2MBHI/src/dates.jl:3 [inlined]
[9] xparse at /home/ubuntu/.julia/packages/Parsers/2MBHI/src/Parsers.jl:254 [inlined]
[10] parsevalue!(::Type{ZonedDateTime}, ::UInt8, ::SentinelArrays.SentinelArray{ZonedDateTime,1,UndefInitializer,Missing,Array{ZonedDateTime,1}}, ::Array{AbstractArray{T,1} where T,1}, ::Array{UInt8,1}, ::Int64, ::Int64, ::Parsers.Options{false,true,true,false,Missing,UInt8,DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.ssszzz"),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.DatePart{'z'}}}}, ::Int64, ::Int64, ::Int64, ::Array{Type,1}, ::Array{UInt8,1}) at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:907
[11] macro expansion at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:620 [inlined]
[12] parsecustom! at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:610 [inlined]
[13] parserow(::Int64, ::Val{false}, ::Int64, ::Dict{Type,Type}, ::Array{AbstractArray{T,1} where T,1}, ::Int64, ::Array{UInt8,1}, ::Int64, ::Int64, ::Array{Int64,1}, ::Float64, ::Array{CSV.RefPool,1}, ::Int64, ::Int64, ::Array{Type,1}, ::Array{UInt8,1}, ::Bool, ::Parsers.Options{false,true,true,false,Missing,UInt8,Nothing}, ::Array{Parsers.Options,1}, ::Type{Tuple{Tuple{SentinelArrays.SentinelArray{ZonedDateTime,1,UndefInitializer,Missing,Array{ZonedDateTime,1}},ZonedDateTime}}}, ::Base.RefValue{Int64}, ::Int64) at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:669
[14] parsefilechunk!(::Val{false}, ::Int64, ::Dict{Type,Type}, ::Array{AbstractArray{T,1} where T,1}, ::Array{UInt8,1}, ::Int64, ::Int64, ::Int64, ::Array{Int64,1}, ::Float64, ::Array{CSV.RefPool,1}, ::Int64, ::Int64, ::Array{Type,1}, ::Array{UInt8,1}, ::Bool, ::Parsers.Options{false,true,true,false,Missing,UInt8,Nothing}, ::Array{Parsers.Options,1}, ::Type{Tuple{Tuple{SentinelArrays.SentinelArray{ZonedDateTime,1,UndefInitializer,Missing,Array{ZonedDateTime,1}},ZonedDateTime}}}, ::Int64) at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:541
[15] CSV.File(::CSV.Header{false,Parsers.Options{false,true,true,false,Missing,UInt8,Nothing},Array{UInt8,1}}; finalizebuffer::Bool, startingbyteposition::Nothing, endingbyteposition::Nothing, limit::Nothing, threaded::Nothing, typemap::Dict{Type,Type}, tasks::Int64, lines_to_check::Int64, maxwarnings::Int64, debug::Bool) at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:303
[16] CSV.File(::String; header::Int64, normalizenames::Bool, datarow::Int64, skipto::Nothing, footerskip::Int64, transpose::Bool, comment::Nothing, use_mmap::Nothing, ignoreemptylines::Bool, select::Nothing, drop::Nothing, missingstrings::Array{String,1}, missingstring::String, delim::Nothing, ignorerepeated::Bool, quotechar::Char, openquotechar::Nothing, closequotechar::Nothing, escapechar::Char, dateformat::Nothing, dateformats::Dict{Symbol,DateFormat{Symbol("yyyy-mm-ddTHH:MM:SS.ssszzz"),Tuple{Dates.DatePart{'y'},Dates.Delim{Char,1},Dates.DatePart{'m'},Dates.Delim{Char,1},Dates.DatePart{'d'},Dates.Delim{Char,1},Dates.DatePart{'H'},Dates.Delim{Char,1},Dates.DatePart{'M'},Dates.Delim{Char,1},Dates.DatePart{'S'},Dates.Delim{Char,1},Dates.DatePart{'s'},Dates.DatePart{'z'}}}}, decimal::UInt8, truestrings::Array{String,1}, falsestrings::Array{String,1}, type::Nothing, types::Dict{Symbol,DataType}, typemap::Dict{Type,Type}, pool::Float64, lazystrings::Bool, strict::Bool, silencewarnings::Bool, debug::Bool, parsingdebug::Bool, kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/ubuntu/.julia/packages/CSV/la2cd/src/file.jl:218 |
ok, after a big Parsers.jl upgrade in time-type parsing functionality recently, doing |
I have Parsers v1.0.15 and CSV v0.8.2 on julia 1.5.3
This issue may be related to #729
I have the following CSV:
I have the following code that stores the
d
column as a String:If I change the code to use
types
, it fails with a parser error. This happens regardless of whether I usedateformats
or not:If I change the
types
value toDateTime
, then I get the same error as in #729The text was updated successfully, but these errors were encountered: