# Reading input parameters from a text file

**URL:** https://discourse.julialang.org/t/reading-input-parameters-from-a-text-file/131737
**Category:** General Usage
**Tags:** question
**Created:** [August 20, 2025, 3:12pm UTC](https://discourse.julialang.org/t/reading-input-parameters-from-a-text-file/131737 "2025-08-20T15:12:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![JonasWickman](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)
#### Post date: [August 20, 2025, 3:34pm UTC](https://discourse.julialang.org/t/reading-input-parameters-from-a-text-file/131737/2 "2025-08-20T15:34:33Z")

</div>

I don’t have any advice on how to store or parse parameters from text files, but if the number of parameters you need to read aren’t too large, it may be better to store them in either a custom struct (if only the values of the parameters change, and not the set of parameters itself) or a NamedTuple. This would entail writing either:

```julia-auto
# Struct
@kwdef struct Params
    num1::Int = 10
    num2::Float64 = 14.6
    num3::Float64 = 1e20
    bool1::Bool = true
    bool2::Bool = false
    option1::String = "string1"
end

params = Params() # Default values
params = Params(num1 = 3) # Change one of the values 

# Named Tuple 
params = (;
    num1 = 10,
    num2 = 14.6,
    num3 = 1e20,
    bool1 = true,
    bool2 = false,
    option1 = "string1"
)

```

If you do this, you can use destructuring by name inside functions, which can be handy for carrying out computations with the parameters:

```julia-auto
function my_function(x, params)
    (; num1, num2, num3) = params 
    x + num1*num2*num3
end

```

This may also yield some performance benefits as the Dict you have above carries a bunch of different types, which means Julia will not typically be able to infer types when using it.

---

_[View the full topic](https://discourse.julialang.org/t/reading-input-parameters-from-a-text-file/131737)._
