I have just started Scala and came from Python.
I would like to read in a '|' delimited file and preserve the structure of the tables. Say I have a file that contains something like this:
1|2|3|4
5|6|7|8
9|10|11|12
I would like a function that would return a structure like this:
List(List(1, 2, 3, 4), List(5, 6, 7, 8), List(9, 10, 11, 12))
My code thus far (doesn't work because of type mismatch):
import scala.io.Source
def CSVReader(absPath:String, delimiter:String): List[List[Any]] = {
println("Now reading... " + absPath)
val MasterList = Source.fromFile(absPath).getLines().toList
return MasterList
}
var ALHCorpus = "//Users//grant//devel//Scala-codes//ALHCorpusList"
var delimiter = "|"
var CSVContents = CSVReader(ALHCorpus, delimiter)