title: How to open a file in the rdd having path to this file?
body: <p>I am working with sentinel images data on apache spark using Scala. 
  At some step I filter metadata that contains specific location and for those data I want to open new file located in subfolder. </p>
  
  <p>Filter rdd contains key as path to file with globalmetadata and  value as path to file which I would like to open.</p>
  
  <pre><code>var global_and_cloud=global_filter.map{case(name, positions_list, granule)=&gt;
  (name, (name.substring(0, name.length-14)+granule.substring(13,56)+"QI_DATA/MSK_CLOUDS_B00.gml"))}
  </code></pre>
  
  <p>The best I can do is </p>
  
  <pre><code>var global_and_cloud2=global_and_cloud.map{case(name, cloud_path)=&gt;
  (sc.wholeTextFiles(cloud_path).first._1, sc.wholeTextFiles(cloud_path).first._2)}
  </code></pre>
  
  <p>but it's throwing exeptions java.lang.NullPointerException when I want to take action on it, </p>
  
  <p>and when I do </p>
  
  <pre><code>sc.wholeTextFiles(global_and_cloud.first._2).first._2
  </code></pre>
  
  <p>i get a content of file so it's exist</p>
  
  <p>Is there any way to read a file inside rdd?</p>