testing1/drumb.scala
changeset 171 4c9497ab5caa
parent 167 349d706586ef
child 199 54befaf23648
equal deleted inserted replaced
170:37b1bfcdba79 171:4c9497ab5caa
    20 
    20 
    21 import io.Source
    21 import io.Source
    22 import scala.util._
    22 import scala.util._
    23 
    23 
    24 def get_january_data(symbol: String, year: Int) : List[String] = 
    24 def get_january_data(symbol: String, year: Int) : List[String] = 
    25   Source.fromFile(symbol ++ ".csv")("ISO-8859-1").getLines.toList.filter(_.startsWith(year.toString))
    25   Source.fromFile(symbol ++ ".csv").getLines.toList.filter(_.startsWith(year.toString))
    26 
    26 
    27 
    27 
    28 def get_first_price(symbol: String, year: Int) : Option[Double] = {
    28 def get_first_price(symbol: String, year: Int) : Option[Double] = {
    29   val data = Try(Some(get_january_data(symbol, year).head)) getOrElse None 
    29   val data = Try(Some(get_january_data(symbol, year).head)) getOrElse None 
    30   data.map(_.split(",").toList(1).toDouble)
    30   data.map(_.split(",").toList(1).toDouble)