# How to store all in Julia

**URL:** <https://discourse.julialang.org/t/how-to-store-all-in-julia/103215>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [August 26, 2023, 1:56am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215 "2023-08-26T01:56:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![R0033h](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Post date:** [August 26, 2023, 1:56am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/1 "2023-08-26T01:56:30Z")

</div>

Could please tell me i want to save all output. what should i do. I tried use CVS and Excel but i could not.  
It means should i create file for each loop i wrote (println) or what.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [August 26, 2023, 2:30am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/2 "2023-08-26T02:30:52Z")

</div>

JLD.jl

> **[GitHub - JuliaIO/JLD.jl: Saving and loading julia variables while preserving...](https://github.com/JuliaIO/JLD.jl)**
>
> Saving and loading julia variables while preserving native types - GitHub - JuliaIO/JLD.jl: Saving and loading julia variables while preserving native types

JLD2.jl

> **[GitHub - JuliaIO/JLD2.jl: HDF5-compatible file format in pure Julia](https://github.com/JuliaIO/JLD2.jl)**
>
> HDF5-compatible file format in pure Julia. Contribute to JuliaIO/JLD2.jl development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![R0033h](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Post date:** [August 26, 2023, 2:37am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/3 "2023-08-26T02:37:43Z")

</div>

Thank you for your reply. I would like to ask you I have many loops and arrays I am not sure how can i save it.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [August 26, 2023, 4:42am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/4 "2023-08-26T04:42:33Z")

</div>

I don’t understand what you mean. Maybe someone else can help.

---

<div class="post-metadata">

**Author:** ![lostella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lostella/32/356_2.png) [@lostella](https://discourse.julialang.org/u/lostella)\
**Post date:** [August 26, 2023, 7:01am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/5 "2023-08-26T07:01:29Z")

</div>

Have you tried reading the documentation from the packages that @mkitti shared? You should find examples there that are similar to your case.

For example, here is the documentation for JLD2: [Basics · Julia Data Format](https://juliaio.github.io/JLD2.jl/stable/)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 26, 2023, 7:21am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/6 "2023-08-26T07:21:51Z")

</div>

Do you want to store all output you see while running the program? Or all global variables? Or something else?

---

<div class="post-metadata">

**Author:** ![R0033h](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Post date:** [August 26, 2023, 8:43am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/7 "2023-08-26T08:43:06Z")

</div>

Thank you for your reply i want to store all output.

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [August 26, 2023, 1:30pm UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/9 "2023-08-26T13:30:33Z")

</div>

It would be very helpful if you write some pseudo-code (code that does not run), where the names of variables and functions show us what you want to happen 🙂

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [August 26, 2023, 2:07pm UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/10 "2023-08-26T14:07:25Z")

</div>

Specifically, it is not clear what you mean by “store all output,” or what loops and arrays have to do with anything. Does “store all output” mean “save the everything that appears in the REPL to a file,” like Matlab’s “diary on”? If not that, what?

To get help your question needs to be clear enough for people to understand what you’re talking about. An example of some code and what you want stored from it would be ideal.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![martincornejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martincornejo/32/13436_2.png) [@martincornejo](https://discourse.julialang.org/u/martincornejo)\
**Post date:** [August 26, 2023, 5:49pm UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/11 "2023-08-26T17:49:06Z")

</div>

Maybe logging the output to a file is what you’re looking for? [Logging · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Logging/#Example:-Writing-log-events-to-a-file)

Example

```julia
# Load the logging module
using Logging

# Open a textfile for writing
io = open("log.txt", "w+")

# Create a simple logger
logger = SimpleLogger(io)

# Set the global logger to logger
global_logger(logger)

# Log a task-specific message
for in in 1:10
   @info i
end

# Write all buffered messages to the file
flush(io)
close(io)

```

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [September 18, 2023, 10:07am UTC](https://discourse.julialang.org/t/how-to-store-all-in-julia/103215/12 "2023-09-18T10:07:40Z")

</div>

By OP’s request I will delete the contents of this comment. A new version of the code will be posted by him.
