Created
August 26, 2010 18:08
-
-
Save bwmcadams/551881 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
val notHaveBlankRows = new Matcher[Iterable[Map[String, String]]] { | |
def apply(x: => Iterable[Map[String, String]]) = { | |
(x().forall(row => row.forall(kv => kv._2 != null && kv._2 != "" && kv._2 != None)), | |
"No blank rows contained in Iterable.", | |
"Blank rows (all values in row are either '', null or None) found in Iterable.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def apply(filename: String, code: String): Iterable[Map[String, String]] = {
val tree = apply(code)
if (filename.toUpperCase.endsWith("XLS")) {
ExcelFile(filename, tree).toMapping
} else if (filename.toUpperCase.endsWith("CSV")) {
CSVFile(filename, tree).iterator
} else {
throw new IllegalArgumentException("Don't know how to parse this file extension (%s)".format(filename))
}
}.filter(row => row.forall(kv => kv._2 != null && kv._2 != "" && kv._2 != None))