Created
August 23, 2012 13:44
-
-
Save davidpelfree/3436736 to your computer and use it in GitHub Desktop.
Easily and quickly parse CSV/TSV 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
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