Created
November 3, 2009 06:05
-
-
Save crystalneth/224839 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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