Reading data matrix from text file in Julia

I have a text file that includes a matrix. I want to read it in julia as a matrix.

The text file looks like this:

0 0 0 0 0 0 0
1 0 0 0 0 0 0
1 0 0 0 0 0 1
1 0 0 0 1 1 0

In Matlab, you can do the following to create a matrix M:

file='name.txt';
[M] = load(file);

How to do the same in Julia?

+4
source share
1 answer
shell> cat /tmp/m.txt
0   0   0   0   0   0   0
1   0   0   0   0   0   0
1   0   0   0   0   0   1
1   0   0   0   1   1   0

julia> m = readdlm("/tmp/m.txt")
4x7 Array{Float64,2}:
 0.0  0.0  0.0  0.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0  0.0  0.0  0.0
 1.0  0.0  0.0  0.0  0.0  0.0  1.0
 1.0  0.0  0.0  0.0  1.0  1.0  0.0
+11
source

Source: https://habr.com/ru/post/1628082/


All Articles