JuliaDB ignoring variables of the wrong type

Hello all. First days in Julia, so please be patient. :slight_smile:

I am reading a table with JuliaDB and one of the variables is an integer. I have declared that with colparsers. Julia gives an error if the variable is not an integer in any of the observations, but instead I would like it to register as empty file, e.g. if the variable equals ‘b’ for some observation, read it as empty.

Thank you.

I am not familiar with JuliaDB so maybe there is a better way to do this, but

try
    # read the file with JuliaDB
catch e
    if e == the_kind_of_exception_JuliaDB_gives
        # return an empty file, whatever that is
    else
        rethrow(e)
    end
end

or something along those lines. See

https://docs.julialang.org/en/v1/manual/control-flow/#The-try/catch-statement

Thank you. Your solution would give me the error, which I kind of know already. I was looking for a possible solution. This should not be difficult. All I want is for JuliaDB to read as integer, or float, of whatever type I desire, and if that is not possible, e.g. a string appears, return the value as empty.

This works:
@time beta = loadtable(“data/data_disaggregated”, colparsers=Dict(:DATE => dateformat"d/m/y",:n => Int64))

But that does not:
@time beta = loadtable(“data/data_disaggregated”, colparsers=Dict(:DATE => dateformat"d/m/y",:n => Int64. :RET => Float64))

The error:
Could not convert column RET of eltype Union{Missing,Float64} to eltype Float64