Skip to content

Instantly share code, notes, and snippets.

@crystalneth
Created November 3, 2009 06:05
Show Gist options
  • Select an option

  • Save crystalneth/224839 to your computer and use it in GitHub Desktop.

Select an option

Save crystalneth/224839 to your computer and use it in GitHub Desktop.
def map[T](f: (Array[String]) => T):List[T] = {
reader.readNext match {
case fields:Array[String] => f(fields) :: map(f)
case _ => Nil
}
}
def map[T](f: (Array[String]) => T):List[T] = {
def _map[T](f: (Array[String] => T), reader:CSVReader):List[T] = {
reader.readNext match {
case fields:Array[String] => f(fields) :: _map(f, reader)
case _ => Nil
}
}
val reader = new CSVReader(new FileReader(file), '\t', '"')
try {
_map(f, reader)
} finally {
reader.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment