title: Android- Select CSV file from Google Drive and parse it in java
body: <p>I am trying to load <strong>CSV</strong> file from Google drive and parse it in java. But whenever I select the file, it show me the Exception: <strong>File not Found</strong>.</p>
  
  <p>Below is my implemented code:</p>
  
  <p>Chooser intent code:</p>
  
  <pre><code>    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
      intent.setType("text/csv");   //XML file only
      intent.addCategory(Intent.CATEGORY_OPENABLE);
      try
      {
          startActivityForResult(Intent.createChooser(intent, "Select"), 100);
      } catch (android.content.ActivityNotFoundException ex)
      {
          // Potentially direct the user to the Market with a Dialog
          Toast.makeText(this, "Drive Not Found", Toast.LENGTH_SHORT).show();
      }
  </code></pre>
  
  <p>onActivity Result:</p>
  
  <pre><code>   @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      switch (requestCode)
      {
          case 100:
              {
              if (resultCode == RESULT_OK)
              {
                  //onImport(new File(data.getData().getPath()));
                  String filePath = null;
                  Uri uri = data.getData();
  
                  File file = new File(uri.toString());
                  if (file.exists()) {
                      //Do something
                      System.out.println("Exists");
                      proImportCSV(new File(data.getData().getPath()));
                  }
                  else
                  {
                      System.out.println("Not Exists");
                  }
  
              }
          }
      }
  }
  </code></pre>
  
  <p>Parsing of CSV using <strong>CSVReader</strong></p>
  
  <pre><code>   private void proImportCSV(File from)
  {
      try
      {
          // reading CSV and writing table
          CSVReader reader = null;
          try
          {
              reader = new CSVReader(new FileReader(from));
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
          String[] nextLine;
          try {
              while ((nextLine = reader.readNext()) != null) {
                  // nextLine[] is an array of values from the line
                  System.out.println(nextLine[0] + nextLine[1] + "etc...");
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Kindly tell me why I am getting file not found error. Plus, Am I parsing the csv rightly? If not right, Then tell me the right one with detail.</p>
  
  <p>Thanks in advance!</p>