Skip to content

Commit

Permalink
parsing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Feb 18, 2025
1 parent 6688da6 commit df6e461
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/MadsIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ function get_excel_data(excel_file::AbstractString, sheet_name::AbstractString="
elseif all(typeof.(v) .<: Union{Missing,AbstractString})
v[ismissing.(v)] .= ""
v = convert(Vector{String}, v)
elseif all(typeof.(v) .<: Union{Number,AbstractString})
v[v .== ""] .= NaN
parsingerror = false
for i in eachindex(v)
if typeof(v[i]) <: AbstractString
if occursin(r"^-*$", v[i])
v[i] = NaN
else
try
v[i] = parse(numbertype, v[i])
catch
parsingerror = true
end
end
end
end
if parsingerror
@warn("Some values for parameter/column \"$(param)\" could not be parsed!")
end
v = convert(Vector{Union{unique(typeof.(v))...}}, v)
else
v = convert(Vector{Union{unique(typeof.(v))...}}, v)
end
Expand Down

0 comments on commit df6e461

Please sign in to comment.