Skip to content

Instantly share code, notes, and snippets.

@davidpelfree
Created August 23, 2012 13:44
Show Gist options
  • Save davidpelfree/3436736 to your computer and use it in GitHub Desktop.
Save davidpelfree/3436736 to your computer and use it in GitHub Desktop.
Easily and quickly parse CSV/TSV line
List<String> values = []
int start, stop
// Quickly parse TSV line
while (true) {
stop = line.indexOf('\t', start)
if (stop < 0) break;
values.push(line.substring(start, stop))
start = stop + 1
}
// Now you got all values in a list / array, just use them:
final def dataCenter = values[0]
final def env = values[1]
final def hostName = values[2]
final def licenseID = values[3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment