I wrote a script parsing a .csv file in groovy using tokenize, which ended up not doing exactly what I needed, I am trying to use the openCSV library but I am unsure as to how I can parse out individual columns. here is my code so far:
List<String[]> rows = new CSVReader(
new InputStreamReader(getClass().classLoader.getResourceAsStream(inputFileString)))
.readAll()
rows.each { row ->
row.each { it ->
println it
}
}
and here is my input data:
1,"unknown","positive","full message","I love it."
So what I am trying to figure out is how to print select columns in said row. Also thanks in advance, I am trying to get my head around groovy/java, I come from a Ruby background.
Not sure what you mean by ‘…how to print select columns in said row’
But this script (for example) prints the 4th column for each row:
That prints: