I need to replicate the result from this array definition using an external file.
scala> val data = Seq(Array(Array(1, 2), Array(3)),Array(Array(1), Array(3, 2), Array(1, 2)),Array(Array(1, 2), Array(5)),Array(Array(6)))
data: Seq[Array[Array[Int]]] = List(Array(Array(1, 2), Array(3)), Array(Array(1), Array(3, 2), Array(1, 2)), Array(Array(1, 2), Array(5)), Array(Array(6)))
I tried creating a testdataI.txt file but can't make it to work.
testdataI.txt ->
1,2
3
1
3,2
1,2
1,2
5
6
Here the result when I do the conversion using io.Source:
import scala.io.Source
scala> val data = Seq(Source.fromFile("/tmp/testdataI.txt").getLines().map(_.split(",").map(_.trim.toInt)).toArray)
data: Seq[Array[Array[Int]]] = List(Array(Array(1, 2), Array(3), Array(1), Array(3, 2), Array(1, 2), Array(1, 2), Array(5), Array(6)))
The outcome should look like this (A series of Multidimensional Arrays)
data: Seq[Array[Array[Int]]] = List(Array(Array(1, 2), Array(3)), Array(Array(1), Array(3, 2), Array(1, 2)), Array(Array(1, 2), Array(5)), Array(Array(6)))
I found a lot of Multidimensional array information but nothing for this specific case.
Really appreciate,
Fredy A Gomez