I’m looking to transform all the files into Array[Array[String]]. The first dimension should be the row number. The second dimension should be the column number. So far I have
for (file <- allFiles) {
val split = for (line <- Source.fromFile(...) yield line.split(",")
} yield split
But it doesn’t seem to be working. As a concrete example if I had
file1.csv
a,b,c
d,e,f
file2.csv
1,2,3
I would want as output
a,b,c
d,e,f
1,2,3
By doing this:
You are iterating over each character from the file, not each line.
You probably meant:
By the way, you can combine your two
forcomprehensions into one: