# Load 2 types of data from a folder

**URL:** <https://discourse.julialang.org/t/load-2-types-of-data-from-a-folder/61921>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 27, 2021, 12:51pm UTC](https://discourse.julialang.org/t/load-2-types-of-data-from-a-folder/61921 "2021-05-27T12:51:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![assia855](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/assia855/32/22845_2.png) [@assia855](https://discourse.julialang.org/u/assia855)\
**Post date:** [May 27, 2021, 12:51pm UTC](https://discourse.julialang.org/t/load-2-types-of-data-from-a-folder/61921/1 "2021-05-27T12:51:17Z")

</div>

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.

```julia

Data = glob("Data_Weight")

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

end

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [May 27, 2021, 5:58pm UTC](https://discourse.julialang.org/t/load-2-types-of-data-from-a-folder/61921/2 "2021-05-27T17:58:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [May 27, 2021, 6:08pm UTC](https://discourse.julialang.org/t/load-2-types-of-data-from-a-folder/61921/3 "2021-05-27T18:08:18Z")

</div>

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

```julia
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).

---

<div class="post-metadata">

**Author:** ![assia855](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/assia855/32/22845_2.png) [@assia855](https://discourse.julialang.org/u/assia855)\
**Post date:** [May 27, 2021, 7:47pm UTC](https://discourse.julialang.org/t/load-2-types-of-data-from-a-folder/61921/4 "2021-05-27T19:47:17Z")

</div>

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

```julia
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)
