How to save an NxNxN array (or Matrix) into a file in Julia (or Python)?

前端 未结 2 1829
清歌不尽
清歌不尽 2021-02-13 00:30

I\'m working on a Jupyter notebook and currently using Julia

I\'m trying to save a 3x3x3 Array into a textfile so when I include it in another notebook, the array is a 3

2条回答
  •  既然无缘
    2021-02-13 01:08

    Okay I admit that I am a python lover, though Julia is starting to grow on me. So as an old python user there is a Julia package that can convert arrays into numpy npz files and then read them as well. Example:

        x = reshape(1:27, 3,3,3)
        Pkg.add("NPZ")
        using NPZ
        npzwrite("TEST.npz",x)
    

    And now I can later load this file (so long as I am using the NPZ package):

        y = npzread("TEST.npz")
    

提交回复
热议问题