You can operate on values (not module attributes) in a module body, do some computations and only then assign them to attributes:
csv_sports_data = :my_app
|> :code.priv_dir()
|> Path.join("awesome_csv.csv")
|> File.stream!()
|> CSV.decode!(headers: false, separator: ?;)
|> Stream.map(&List.to_tuple/1)
|> Stream.uniq()
|> Enum.map(fn {sport, country, league} ->
{String.trim(sport), String.trim(country), String.trim(league)}
end)
@csv_sports_data csv_sports_data
And re-use the already computed value to declare other module attributes:
@sports csv_sports_data
|> Enum.map(fn {sport, _country, _league} -> sport end)
|> Enum.filter(fn sport -> sport != "" end)
@countries csv_sports_data
|> Enum.map(fn {_sport, country, _league} -> country end)






















