progs/yahoo.scala
changeset 266 ca48ac1d3c3e
equal deleted inserted replaced
265:59779ce322a6 266:ca48ac1d3c3e
       
     1 import io.Source
       
     2 import scala.util._
       
     3 
       
     4 object Foo {
       
     5   
       
     6 def get_data(symbol: String) : List[String] = 
       
     7   Source.fromFile(symbol ++ ".csv")("ISO-8859-1").getLines.toList
       
     8 
       
     9 def process(s: String) : String = {
       
    10   val l = s.split(",").toList
       
    11   l(0) + "," + l(5)
       
    12  }
       
    13 
       
    14 def clean(sym: String) = {
       
    15   val da = get_data(sym)
       
    16   val out = 
       
    17     for (l <- da;
       
    18 	 if l.drop(4).startsWith("-01")) yield process(l)
       
    19 
       
    20   println(process(da.head))
       
    21   out.foreach { println }
       
    22 
       
    23 }
       
    24 
       
    25 
       
    26 def main(args: Array[String]) = clean(args(0))
       
    27 
       
    28 }