Java: How to compare columns of a CSV file and print specific lines
<p>I'm new to Java programming and I've been tasked to parse a CSV file and print out the correct row of the CSV file, by comparing columns e.g. the lines printed need to have a unique 1st and 2nd column, that the 3rd column must contain "no" and that the 4th column has a value greater or equal to 
12.</p>

<p>There are 5 columns in total.</p>

<p>Also I'm not allowed to use any libraries that parse the CSV for you.</p>

<p>Here is my code so far: </p>

<pre><code>private static String[] routerData;

public static void main(String [] args)  {

    // Input of file which needs to be parsed
    String csvFile = "./sample.csv";
    BufferedReader csvReader = null;

    // Data split by ',' in CSV file
    String line = null;
    String csvSplitBy = ",";

    try {

        // Create the CSV file reader
        csvReader = new BufferedReader(new FileReader(csvFile));
        while ((line = csvReader.readLine()) !=null) {

            routerData = line.split(csvSplitBy, -1);
            System.out.println(routerData[0] + ", " + routerData[1] + ", " + routerData[2] + ", " + routerData[3] + ", " + routerData[4]);

        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (csvReader != null) {
            try {
                csvReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
</code></pre>

<p>}</p>

<p><strong>Edit</strong> Sample CSV:</p>

<p>For example,  a sample CSV file would look like this:</p>

<pre><code>Name,IP,Working?,Version,Comments
name,0.0.0.0,No,11.2,Some GUI Bugs
name2,0.1.2.0,Yes,12.3,
name,0.0.1.0,Yes,12.2,Case broken,
name4,0.0.0.0,no,10.3
</code></pre>

<p>So the code has to take a CSV file and then print out the rows that have a Unique name (1st column), Unique IP (2nd column), "No" for 'Working?' (3rd column) and a version value above 12. </p>

<p>I'm not sure what Data structure to use that will allow me to compare columns.</p>

<p>I'm very thankful for any advice! </p>