Created
October 28, 2016 12:42
-
-
Save batmat/b36e35c72b0105a6e5f6b6cccab76c70 to your computer and use it in GitHub Desktop.
Quick & Dirty JSON => CSV converter for http://stats.jenkins.io/plugin-installation-trend/jvms.json
This file contains 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
import groovy.json.* | |
def slurper = new groovy.json.JsonSlurper() | |
def result = slurper.parse(new File('jvms.json')) | |
def vget(def map, def key) { | |
map.get(key) ?: "0" | |
} | |
final def JVM_VERSIONS = ["1.5", "1.6", "1.7", "1.8", "1.9"] | |
println 'timestamp,' + JVM_VERSIONS.join(',') | |
result['jvmStatsPerMonth'].each { month_map -> | |
println month_map.key + "," + ( JVM_VERSIONS.collect { vget(month_map.value, it) }.join(',') ) | |
} | |
println "timestamp,1.7,1.8" | |
result['jvmStatsPerMonth_2_x'].each { month_map -> | |
println month_map.key + "," + ( ["1.7", "1.8"].collect { vget(month_map.value, it) }.join(',') ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment