単にCSVである行が,
で分割され、それらの値からTempData
インスタンスが作成されます。
例を参照して、
scala> TempData(year=p(1).toInt, month=p(4).toInt, Prec=p(5).toDouble, Maxtemp=p(6).toInt, Meantemp=p(7).toInt, Mintemp=p(8).toInt)
res2: TempData = TempData(2017,10,5.0,1000,2000,3000)
に相当する
scala> case class TempData(year:Int,month:Int,Prec:Double,Maxtemp:Int,Meantemp:Int,Mintemp:Int)
defined class TempData
scala> val p = "whatever,2017,whatever,whatever,10,5.0,1000,2000,3000".split(",")
p: Array[String] = Array(whatever, 2017, whatever, whatever, 10, 5.0, 1000, 2000, 3000)
scala> TempData(p(1).toInt,p(4).toInt,p(5).toDouble,p(6).toInt,p(7).toInt,p(8).toInt)
res1: TempData = TempData(2017,10,5.0,1000,2000,3000)
はスカラで約String#splitまたcase classesを読み取ります。
コンマで区切られた 'line'文字列を' TempData'クラスに解析するようです。 – Brian