title: Java - Most efficient way to read in a CSV file with various data types
body: <p>I'm attempting to read in a CSV file with various data types. </p>
  
  <p>A row of the sheet would be like below:</p>
  
  <p><em>Single, Monthly, Accelerated, John, Smith, 08/15/1951, Yes</em></p>
  
  <p>I then need to assign each field to a variable name, preform some calculations, print an output and then move onto the next line in the excel sheet</p>
  
  <p>Up until now, I've been using the below</p>
  
  <pre><code>ArrayList&lt;String&gt; lines = new ArrayList&lt;&gt;();
  try {
      BufferedReader reader = new BufferedReader(new FileReader(fileName));
      String line = null;
      while ((line = reader.readLine()) != null) {
          lines.add(line);
          }
  </code></pre>
  
  <p>But this creates an array with each slot containing a long string with the text (including comma) of the corresponding excel row. 
  This seems inefficient and impractical as i then have to traverse each slot/string to extract the values.</p>
  
  <p>Once I have the methodology, I wont have any issue writing the code but i don't know the best way to go about it</p>
  
  <p>Is it better to read each cell separately and assign to a variable ?
  Or is it better to read in a file once and traverse it afterwards? 
  Perhaps there is a more efficient way to do this task</p>
  
  <p>Edit : I also though of attempting to read in the entire CSV file as a 2D array, but the different data types could be an issue..?</p>