From a696075ada2c5c3f84dc7c46634e7f26b55c989c Mon Sep 17 00:00:00 2001 From: Ally Hawkins <54039191+allyhawkins@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:05:44 -0400 Subject: [PATCH 1/4] parse NAs when reading in json --- lib/Utils.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Utils.groovy b/lib/Utils.groovy index fa61a6af..cebda435 100644 --- a/lib/Utils.groovy +++ b/lib/Utils.groovy @@ -15,6 +15,8 @@ class Utils { */ static def readMeta(file) { def meta = new JsonSlurper().parse(file) + meta = meta.each{ key, value -> meta[key] = Utils.parseNA(value) } + return(meta) } @@ -38,8 +40,9 @@ class Utils { */ static def getMetaVal(file, key){ def obj = new JsonSlurper().parse(file) + value = Utils.parseNA(obj[key]) - return(obj[key]) + return(value) } From cd8135c9116373cc57fa0b681f5e5d736b9cbbb9 Mon Sep 17 00:00:00 2001 From: Ally Hawkins Date: Thu, 26 Oct 2023 09:25:56 -0500 Subject: [PATCH 2/4] update parseNA to deal with non strings --- lib/Utils.groovy | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Utils.groovy b/lib/Utils.groovy index cebda435..49bb6b85 100644 --- a/lib/Utils.groovy +++ b/lib/Utils.groovy @@ -55,9 +55,12 @@ class Utils { */ static def parseNA(str) { if (str){ - str.toLowerCase() in ['na','n/a','nan']? '' : str - } else { + if (str instanceof String) { // has to be a string to have NA vals replaced + str.toLowerCase() in ['na','n/a','nan']? '' : str + } else { // not a string, so just return the unmodified value + str + } + } else { // all falsey values get turned into empty strings '' } - } } From d1fa12b4ed9da32fe647d676fda20e037b58cbef Mon Sep 17 00:00:00 2001 From: Ally Hawkins Date: Thu, 26 Oct 2023 11:15:59 -0500 Subject: [PATCH 3/4] Use this and missing bracket --- lib/Utils.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Utils.groovy b/lib/Utils.groovy index 49bb6b85..de3df690 100644 --- a/lib/Utils.groovy +++ b/lib/Utils.groovy @@ -15,7 +15,7 @@ class Utils { */ static def readMeta(file) { def meta = new JsonSlurper().parse(file) - meta = meta.each{ key, value -> meta[key] = Utils.parseNA(value) } + meta = meta.each{ key, value -> meta[key] = this.parseNA(value) } return(meta) } @@ -40,7 +40,7 @@ class Utils { */ static def getMetaVal(file, key){ def obj = new JsonSlurper().parse(file) - value = Utils.parseNA(obj[key]) + def value = this.parseNA(obj[key]) return(value) } @@ -63,4 +63,5 @@ class Utils { } else { // all falsey values get turned into empty strings '' } -} + } +} \ No newline at end of file From bddcbd1c8ade4548f9a9ed362d9594c9104af0ce Mon Sep 17 00:00:00 2001 From: Ally Hawkins Date: Thu, 26 Oct 2023 11:23:02 -0500 Subject: [PATCH 4/4] new line --- lib/Utils.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Utils.groovy b/lib/Utils.groovy index de3df690..01242ac4 100644 --- a/lib/Utils.groovy +++ b/lib/Utils.groovy @@ -64,4 +64,4 @@ class Utils { '' } } -} \ No newline at end of file +}