Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dshvedchenko/e45a9d1690c43d4e72f58e59eb80ed4f to your computer and use it in GitHub Desktop.
Save dshvedchenko/e45a9d1690c43d4e72f58e59eb80ed4f to your computer and use it in GitHub Desktop.
// input can be CSV in Text, File, anything
def getLHMapFromCSV(fis) {
def data = fis.readLines()
def headers = data.take(1)[0].split(',').collect{it.trim().toLowerCase()}.withIndex(0).collectEntries{i,p -> [(p):i]}
data.drop(1).collect{it.split(',').collect{it}.withIndex(0).collectEntries{i,p -> [(headers[p]):i]}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment