'How to add column values to an array when reading a CSV in Java
I am trying to compare two different csv files, and I need each column saved into a different array to compare these values. My current code reads line by line, but I am not sure how to separate each line to get just a single cell value to add to an array (or arraylist). I have this code so far to read the CSV. I am using opencsv.
public static void main(String[] args) {
ArrayList<String> table = new ArrayList<String>();
try {
CSVReader reader = new CSVReader (new FileReader("src/A.csv"));
String [] nextline;
while ((nextline = reader.readNext()) != null) {
for(String token : nextline) {
//do something to add column value to array
}**
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
