CSV.read with really small decimal value

CSV.read runs into the following error if there is a value below 5e-324.

ERROR: MethodError: no method matching /(::Base.TwicePrecision{Float64}, ::Base.TwicePrecision{Float64})
Closest candidates are:
  /(::Base.TwicePrecision, ::Number) at twiceprecision.jl:495
  /(::DataValues.DataValue{T1}, ::T2) where {T1, T2} at /Users/youngjaewoo/.julia/v0.6/DataValues/src/scalar/operations.jl:55
  /(::T1, ::DataValues.DataValue{T2}) where {T1, T2} at /Users/youngjaewoo/.julia/v0.6/DataValues/src/scalar/operations.jl:65

One hack is to read the numeric column as String and then parse them manually which converts numbers below 5e-324 into 0s. This is true in Julia 0.6.4.

How can this be done better? Any idea?

Upgrade to 0.7/1.0! This is fixed in the current release of CSV.

2 Likes

Thanks! I just tested with Julia 0.7 yet it now mis-represents the scientific notation.

For instance, 4.12e-551 gets imported as 4.12e-243

I think this is a problem for those who use these small values.

29%20AM

You can try CSVFiles.jl, it uses a different implementation.