title: How To Compare Values Between Two Different Sized Csv Files?
body: <p>I was wondering what is the most appropriate way of looping through two csv files and comparing their columns. Specifically I want to compare the csv file1 1st column to every iteration of csv file2 column 20 and check to see if there is a match. Here is what i have so far. In addition csv file1 is considerably smaller than csv file2.</p>
  
  <pre><code>public class ClassifyData {
  
  public static void main(String[]args) throws IOException{
  
  File file1 = new File("file1.csv");
  
  File file2 = new File("file2.csv");
  FileWriter writer = new FileWriter("/Users/home/Work.csv");
  PrintWriter pw = new PrintWriter(writer);
  Scanner in = new Scanner(file1);
  Scanner in2 = new Scanner(file2);
  boolean firstLine = true;
  String[] temp = null;
  String [] temp2 = null;
  String line = null;
  String line2 = null;
  
  while((line = in.nextLine())!=null){
  
      temp= line.split(",");  
  while(line2 = in2.nextLine() !=null){
      temp2 = line2.split(",");
  
  
      if(temp[0] == temp[20]){
          System.out.println("match");
          pw.append("0");
          continue;
  
      }
  
  
  
  
      pw.append("\n");
  
      }
  }
  
  pw.flush();
  pw.close();
  writer.close();
  
  }
  
      }
  </code></pre>