progs/yahoo.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Wed, 25 Nov 2020 17:39:20 +0000
changeset 371 14f2bd9db45b
parent 266 ca48ac1d3c3e
permissions -rw-r--r--
updated

import io.Source
import scala.util._

object Foo {
  
def get_data(symbol: String) : List[String] = 
  Source.fromFile(symbol ++ ".csv")("ISO-8859-1").getLines.toList

def process(s: String) : String = {
  val l = s.split(",").toList
  l(0) + "," + l(5)
 }

def clean(sym: String) = {
  val da = get_data(sym)
  val out = 
    for (l <- da;
	 if l.drop(4).startsWith("-01")) yield process(l)

  println(process(da.head))
  out.foreach { println }

}


def main(args: Array[String]) = clean(args(0))

}