I have a script that I have used regularly in the past to read a CSV-file and output a PostgreSQL-dumpfile to create a table and populate it with data.
This script does not work anymore and it seems that something has changed in the CSV-library.
My version: Version 0.6.3-pre.0 (2017-12-18 07:11 UTC)
Code:
julia> CSV.read("/home/js/Downloads/data-1512997404715.csv")
ERROR: MissingException: encountered a missing value for a non-null column type on row = 686, col = 3
Stacktrace:
[1] (::CSV.##4#5)(::Int64, ::Int64) at /home/js/.julia/v0.6/CSV/src/parsefields.jl:122
[2] parsefield(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Type{WeakRefString{UInt8}}, ::CSV.Options{Void}, ::Int64, ::Int64, ::Base.RefValue{CSV.ParsingState}, ::CSV.##4#5) at /home/js/.julia/v0.6/CSV/src/parsefields.jl:233
[3] parsefield at /home/js/.julia/v0.6/CSV/src/parsefields.jl:315 [inlined]
[4] parsefield at /home/js/.julia/v0.6/CSV/src/parsefields.jl:129 [inlined] (repeats 2 times)
[5] streamfrom at /home/js/.julia/v0.6/CSV/src/Source.jl:209 [inlined]
[6] macro expansion at /home/js/.julia/v0.6/DataStreams/src/DataStreams.jl:542 [inlined]
[7] stream!(::CSV.Source{Base.AbstractIOBuffer{Array{UInt8,1}},Void}, ::Type{DataStreams.Data.Field}, ::DataFrames.DataFrameStream{Tuple{CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Union{}},CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Union{}},CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Union{}},CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Union{}},Array{Int64,1},Array{Int64,1},CategoricalArrays.CategoricalArray{Union{Missings.Missing, String},1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Missings.Missing},CategoricalArrays.CategoricalArray{Union{Missings.Missing, String},1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Missings.Missing},CategoricalArrays.CategoricalArray{Union{Missings.Missing, String},1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Missings.Missing},CategoricalArrays.CategoricalArray{Union{Missings.Missing, String},1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Missings.Missing},CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Union{}},CategoricalArrays.CategoricalArray{String,1,UInt32,String,CategoricalArrays.CategoricalString{UInt32},Union{}}}}, ::DataStreams.Data.Schema{true,Tuple{CategoricalArrays.CategoricalString{UInt32},CategoricalArrays.CategoricalString{UInt32},CategoricalArrays.CategoricalString{UInt32},CategoricalArrays.CategoricalString{UInt32},Int64,Int64,Union{CategoricalArrays.CategoricalString{UInt32}, Missings.Missing},Union{CategoricalArrays.CategoricalString{UInt32}, Missings.Missing},Union{CategoricalArrays.CategoricalString{UInt32}, Missings.Missing},Union{CategoricalArrays.CategoricalString{UInt32}, Missings.Missing},CategoricalArrays.CategoricalString{UInt32},CategoricalArrays.CategoricalString{UInt32}}}, ::Int64, ::NTuple{12,Base.#identity}, ::DataStreams.Data.##15#16, ::Array{Any,1}, ::Type{Ref{(:ut, :combined_name, :first_name, :author_role, :author_position, :addr_no, :email, :pref_name, :organisation, :suborgname, :city, :country)}}) at /home/js/.julia/v0.6/DataStreams/src/DataStreams.jl:614
[8] #stream!#17(::Bool, ::Dict{Int64,Function}, ::Function, ::Array{Any,1}, ::Array{Any,1}, ::Function, ::CSV.Source{Base.AbstractIOBuffer{Array{UInt8,1}},Void}, ::Type{DataFrames.DataFrame}) at /home/js/.julia/v0.6/DataStreams/src/DataStreams.jl:490
[9] (::DataStreams.Data.#kw##stream!)(::Array{Any,1}, ::DataStreams.Data.#stream!, ::CSV.Source{Base.AbstractIOBuffer{Array{UInt8,1}},Void}, ::Type{DataFrames.DataFrame}) at ./<missing>:0
[10] #read#47(::Bool, ::Dict{Int64,Function}, ::Bool, ::Array{Any,1}, ::Function, ::String, ::Type{T} where T) at /home/js/.julia/v0.6/CSV/src/Source.jl:314
[11] read(::String) at /home/js/.julia/v0.6/CSV/src/Source.jl:313
According to CSV’s latest documentation the default for CSV is to handle null values:
“nullable::Bool; indicates whether values can be nullable or not; true by default. If set to false and missing values are encountered, a NullException will be thrown”
How can CSV decide which column is a “non-null column type”?
Regards
Johann