Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Mar 28, 2024
1 parent f542a35 commit 78e0c62
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/MadsIO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function get_datasets(filename::AbstractString)
return datasets
end

function load_data(filename::AbstractString; dataset="", first_row::Union{Nothing,Int}=nothing)::DataFrames.DataFrame
function load_data(filename::AbstractString; dataset="", first_row::Union{Nothing,Int}=nothing)::Union{DataFrames.DataFrame,AbstractArray}
if !isfile(filename)
@warn("File $(filename) does not exist!")
return DataFrames.DataFrame()
Expand Down Expand Up @@ -94,7 +94,7 @@ function load_data(filename::AbstractString; dataset="", first_row::Union{Nothin
c = DataFrames.DataFrame(XLSX.readtable(filename, datasets[1]; stop_in_empty_row=false, header=true, first_row=first_row))
end
catch
@error("File $(filename) cannot be opened!")
@error("Data from File $(filename) cannot be opened!")
c = DataFrames.DataFrame()
end
elseif ((e == ".jld") || (e == ".jld2"))
Expand All @@ -113,8 +113,15 @@ function load_data(filename::AbstractString; dataset="", first_row::Union{Nothin
@info("Dataset $(datasets[1]) loaded from $(filename) ...")
c = ds[datasets[1]]
end
if typeof(c) <: DataFrames.DataFrame
c = c
elseif length(size(c)) == 2
c = DataFrames.DataFrame(c, :auto)
else
c = c
end
catch
@error("File $(filename) cannot be opened!")
@error("Data from File $(filename) cannot be opened!")
c = DataFrames.DataFrame()
end
else
Expand Down

0 comments on commit 78e0c62

Please sign in to comment.