progs/yahoo.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 23 Nov 2020 02:43:03 +0000
changeset 365 fc118ee0fce4
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))

}