# Saving/Loading folders with DrWatson.jl

**URL:** <https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741>\
**Category:** General Usage\
**Tags:** drwatson\
**Created:** [March 8, 2021, 4:06pm UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741 "2021-03-08T16:06:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gobs](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@gobs](https://discourse.julialang.org/u/gobs)\
**Post date:** [March 8, 2021, 4:06pm UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/1 "2021-03-08T16:06:24Z")

</div>

Hello! I started trying [DrWatson](https://github.com/JuliaDynamics/DrWatson.jl) out in the hope of tidying up my currently very messy workflow. I’ve run into a problem however - I save two custom types by saving various .csv and .yaml files into a folder. I then load these types by pointing to that folder, i.e.:

```julia
save(my_type, save_dir)
my_type = load(::MyType, save_dir)

```

Is this compatible with the DrWatson workflow somehow?

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [March 8, 2021, 6:47pm UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/2 "2021-03-08T18:47:13Z")

</div>

Hey @gobs - I am a huge fan of DrWatson and would be happy to try to address your question! However, I am a bit confused by what you mean by “custom” types when it seems you only have CSV and yaml files… Could you explain more what you are trying to do?

Offhand, `datadir` might be of interest for you to check out here: [Project Setup · DrWatson](https://juliadynamics.github.io/DrWatson.jl/dev/project/#Navigating-a-Project-1)

---

<div class="post-metadata">

**Author:** ![gobs](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@gobs](https://discourse.julialang.org/u/gobs)\
**Post date:** [March 9, 2021, 8:28am UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/3 "2021-03-09T08:28:38Z")

</div>

I realize now it’s probably confusing. What I meant was that when I save `MyType`, it saves a `.csv` and a `.yaml` file in a folder. To load an instance of `MyType` again, I specify the folder where it should be loaded from. This is different to e.g. saving it as a `.bson` file, so I was wondering if DrWatson could accomodate this, i.e. how can I overload `_wsave` for my type if that’s even possible?

---

<div class="post-metadata">

**Author:** ![gobs](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@gobs](https://discourse.julialang.org/u/gobs)\
**Post date:** [March 10, 2021, 9:54am UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/4 "2021-03-10T09:54:44Z")

</div>

@Datseris perhaps you could enlighten me on this?

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [March 10, 2021, 9:14pm UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/5 "2021-03-10T21:14:57Z")

</div>

Hello,

thanks for the interest. As you said yourself, the correct way is to overload `_wsave`, as is discussed in the opening section here: **[Saving Tools · DrWatson](https://juliadynamics.github.io/DrWatson.jl/dev/save/#Saving-Tools-1)**.

They way to do it is quite simple:

```julia
using DrWatson
function DrWatson._wsave(filename::String, x::YourCustomType)
    # whatever saves `x` as a .csv file.
end

```

As I don’t know the workings of your type, I’m not sure how you would incorporate `tagsave` into it. But at least now you get for free `safesave` and `wsave`, both of which automatically make the path-to-be-saved (something that FileIO doesn’t do and I find irritating).

---

<div class="post-metadata">

**Author:** ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Post date:** [March 10, 2021, 9:40pm UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/6 "2021-03-10T21:40:39Z")

</div>

Maybe it’s time to think about some trait or public API to make this feel less of hack 😉

---

<div class="post-metadata">

**Author:** ![gobs](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@gobs](https://discourse.julialang.org/u/gobs)\
**Post date:** [March 11, 2021, 8:20am UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/7 "2021-03-11T08:20:41Z")

</div>

Thanks @Datseris ! It might be useful to make this more explicit in the documentation. Also does the same apply for `_wload` (if that exists)?

My original question however is subtlely different - I don’t save my type to a `.csv`, I save it to a directory which contains the necessary `.csv` and `.yaml` files to load the type. My question then was more about whether saving to a **directory** instead of a **file** will break any of the functionality of DrWatson?

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [March 17, 2021, 1:58pm UTC](https://discourse.julialang.org/t/saving-loading-folders-with-drwatson-jl/56741/8 "2021-03-17T13:58:42Z")

</div>

In general file paths are recoverd through `projectdir()` and derivatives, so if you can use this then you should be good to go.

`_wload` doesn’t exist, only `wload` is necessary!
