# How to import to a Matrix data defined in the code script

**URL:** <https://discourse.julialang.org/t/how-to-import-to-a-matrix-data-defined-in-the-code-script/54452>\
**Category:** General Usage\
**Tags:** question, array, dataframes, csv, io\
**Created:** [February 2, 2021, 11:55am UTC](https://discourse.julialang.org/t/how-to-import-to-a-matrix-data-defined-in-the-code-script/54452 "2021-02-02T11:55:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 2, 2021, 11:55am UTC](https://discourse.julialang.org/t/how-to-import-to-a-matrix-data-defined-in-the-code-script/54452/1 "2021-02-02T11:55:32Z")

</div>

For a DataFrame I can do:

```julia

coeff = CSV.read(IOBuffer("""
-400 -100 1 0 0 0
0 -300 0 1 0 0
1 0 0 0 -1 0
0 1 0 0 0 -1
0.8 0.4 0 0 0 0
0.5 1 0 0 0 0
200 100 0 0 0 0
0 0 0 0 800 1200
"""), DataFrame, delim=" ", ignorerepeated=true, header=false)

```

(and then I could use `coeff2 = Matrix(coeff)`)

But is there a more direct way? CSV with Matrix as sink doesn’t work and `coeff = readdlm(IOBuffer("""...` doesn’t have the ignorerepeated option…

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 2, 2021, 12:16pm UTC](https://discourse.julialang.org/t/how-to-import-to-a-matrix-data-defined-in-the-code-script/54452/2 "2021-02-02T12:16:59Z")

</div>

Any particular reason why you can’t use the appropriate syntax for this, i.e. something like

```julia
coeff = [1 2 3;
         4 5 6;
         7 8 9]

```

?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 2, 2021, 12:21pm UTC](https://discourse.julialang.org/t/how-to-import-to-a-matrix-data-defined-in-the-code-script/54452/3 "2021-02-02T12:21:07Z")

</div>

yes you are right, at the end is just typing some semicolons…
