tk3369 / SASLib.jl

Julia library for reading SAS7BDAT data sets
Other
34 stars 7 forks source link

BoundsError when reading sas_to_csv/test_files/hltheds2006.sas7bdat #45

Closed tk3369 closed 6 years ago

tk3369 commented 6 years ago

Ref: https://github.com/ppham27/sas_to_csv/blob/master/test_files/hltheds2006.sas7bdat

julia> readsas("/Users/tomkwong/Downloads/sas_to_csv/test_files/hltheds2006.sas7bdat")
ERROR: BoundsError: attempt to access 30-element Array{UInt8,1} at index [31]
Stacktrace:
 [1] _fill_column_indices(::SASLibProd.Handler) at /Users/tomkwong/.julia/v0.6/SASLibProd/src/SASLibProd.jl:1594
 [2] read_chunk(::SASLibProd.Handler, ::Int64) at /Users/tomkwong/.julia/v0.6/SASLibProd/src/SASLibProd.jl:881
 [3] macro expansion at ./util.jl:293 [inlined]
 [4] read(::SASLibProd.Handler, ::Int64) at /Users/tomkwong/.julia/v0.6/SASLibProd/src/SASLibProd.jl:76
 [5] #readsas#16(::String, ::Bool, ::Array{Any,1}, ::Array{Any,1}, ::Dict{Any,Any}, ::Dict{Any,Any}, ::Dict{Symbol,Type}, ::Int64, ::SASLibProd.#readsas, ::String) at /Users/tomkwong/.julia/v0.6/SASLibProd/src/SASLibProd.jl:165
 [6] readsas(::String) at /Users/tomkwong/.julia/v0.6/SASLibProd/src/SASLibProd.jl:160
tk3369 commented 6 years ago

Debug notes: The _process_columnattributes_subheader function assumes that it's only called once but it turns that that it's not always the case. This file has 217 columns and this subheader appears twice (187 and 30). The fix is simple -- append new column attributes when we encounter a new subheader.

tk3369 commented 6 years ago

Fixed in v0.6.2