vteial
8/19/2015 - 3:07 AM

CsvFileReader.groovy

def regex = ~/\G(?:^|,)(?:"([^"]*+)"|([^",]*+))/

new File('path/to/file.csv').eachLine { line ->
    def columns = []
    def matcher = regex.matcher(line)
    while (matcher.find()) {
        columns << (matcher.group(1) ?: matcher.group(2))
    }
    println columns
}