DrWatson.jl: How to put a float 1e15 in the name? and how to save txt files?

Hello everyone?
As the title says, it’s a DrWatson.jl related question.
Actually, I have 2 questions

Question 1

Let’s say I have

julia> using DrWatson
julia> params = Dict(:a=>1e15, :b=>1:23)
Dict{Symbol,Any} with 2 entries:
  :a => 1.0e15
  :b => 1:23

And now when I make the file name using the function savename, I get:

julia> savename(params,"bson")

which obviously I would prefer to be


Using the scientific keyword is of no help:

julia> savename(params,"bson"; scientific =3)

A similar topic was discussed in this issue

Any help would be greatly appreciated.

Question 2

Are people using DrWatson to save txt files or csv files?
The workflow works very well for BSON files, but if anyone is using other file formats like txt or csv, I would love to see it.
This question comes from the fact that I cannot use the function savename directly in writedlm from DelimitedFiles since the directories will not be created automatically.

Thanks again,

For 1: I see this as the same as the issue you cite, which unfortunately is still open.

For 2: One approach I use is to dispatch on _wsave as described here: https://juliadynamics.github.io/DrWatson.jl/dev/save/#Saving-Tools-1 . Specifically you could do:

DrWatson._wsave(filename, x::YourType) = writedlm(filename, x) 

This way you get auto-path creation by saving the file using wsave instead of writedlm, and you can also use safesave for free.

Although here I guess YourType is just Matrix, and the above would be Type Piracy, but given that DrWatson is an exclusively frontend package I think you can live with it…

Thanks a lot!
That’s very helpful.
I’ll try this

1 Like