Last active
March 17, 2022 19:24
-
-
Save cmaggiulli/3e260e13c723925c11f437c8d45e8fa1 to your computer and use it in GitHub Desktop.
Parse KTR
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
| import groovy.io.FileType | |
| import groovy.xml.* | |
| def dirStr = "C:\\integration\\Pentaho\\Projects\\content\\public" | |
| def dir = new File(dirStr) | |
| def slurper = new XmlSlurper() | |
| def connFileMap = [:] | |
| File outputFile = new File("c:\\Users\\CMaggiul\\connections.csv") | |
| dir.eachFileRecurse(FileType.FILES) { file -> | |
| xmlFile = file.path | |
| xmlFileName = file.name | |
| connList = [] | |
| def csv = "" | |
| if( file.name.endsWith('ktr') ) { | |
| xml = new XmlParser().parse(xmlFile) | |
| csv += "${xmlFileName},${xmlFile}" | |
| xml.connection.each { | |
| connName = it.name.text() | |
| if( connName ) { | |
| csv += ",${connName}" | |
| connList.add( connName ) | |
| } | |
| } | |
| outputFile.withWriterAppend{ out -> | |
| out.println csv | |
| } | |
| connFileMap.put(xmlFileName, connList) | |
| } else if ( file.name.endsWith('kjb') ) { | |
| // Do Nothing For Now | |
| } | |
| } | |
| print connFileMap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment