Load 2 types of data from a folder

Hello folks,

I have 2 types of data in Data folder. I would like to loop through it. How can I make it work please.


Data = glob("Data_Weight")

Load_Data("Data_Weight/Model_Synthetic_Star_/*", 
                         "Data_Weight/Weight_Synthetic_Star_/*")

end

Your question is very unspecific, so as a first step I refer you to
https://docs.julialang.org/en/v1/base/file
where you e.g. find:
readdir()
or
walkdir(".")

1 Like

If you want to use Glob.jl then something like this can be useful

for name in glob("Model_Synthetic_Star_/*", "Data_Weight")
# load first portion of data using `name` of the file
end

for name in glob("Weight_Synthetic_Star_/*", "Data_Weight")
# load second portion of data
end

First argument of glob defines search paths and second argument defines root (and all paths are calculated relative to this root).

1 Like

Thank you for your suggestion.
I developed this code. I would like to enter inside of it, but I have an error.

using Glob
using EasyFITS


for names in glob("model/*")
    for name in glob("weight/*")

        DATA = read(FitsArray, names)
        WEIGHT = read(FitsArray, name)
        DATA = names[:,:,:]
        WEIGHT= name[:,:,:]

    end
end

Error:
ERROR: LoadError: MethodError: no method matching getindex(::String, ::Colon, ::Colon, ::Colon)