* simplify csv lookup and replacement of values based on csv mappings
This commit is contained in:
parent
62732521c5
commit
08cf9720e8
|
@ -5,6 +5,7 @@ import java.util.regex.Pattern
|
|||
|
||||
// simplified switch/case pattern matching
|
||||
Object.metaClass.match = { Map cases -> def val = delegate; cases.findResult { switch(val) { case it.key: return it.value} } }
|
||||
def csv(path, delim = ';', keyIndex = 0, valueIndex = 1) { def f = path as File; def values = [:]; f.splitEachLine(delim) { values.put(it[keyIndex], it[valueIndex]) }; return values }
|
||||
def c(c) { try { c.call() } catch (Throwable e) { null } }
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue