Created
July 14, 2015 16:04
-
-
Save trisberg/abe55a2fc7c3a5b548f2 to your computer and use it in GitHub Desktop.
Convert Map to CSV line
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
def result = "" | |
def delim = "," | |
def enclose = "\"" | |
payload.each { key, value -> | |
if (value instanceof String) { | |
csvValue = enclose + value + enclose | |
} | |
else { | |
csvValue = value | |
} | |
if (result.length() > 0) { | |
result += delim | |
} | |
result += csvValue | |
} | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
List of maps to CSV with headers
Result