title: How to read gz files in Spark using wholeTextFiles
body: <p>I have a folder which contains many small .gz files (compressed csv text files). I need to read them in my Spark job, but the thing is I need to do some processing based on info which is in the file name. Therefore, I did not use:</p>
  
  <pre><code>JavaRDD&lt;&lt;String&gt;String&gt; input = sc.textFile(...)
  </code></pre>
  
  <p>since to my understanding I do not have access to the file name this way. Instead, I used:</p>
  
  <pre><code>JavaPairRDD&lt;&lt;String&gt;String,String&gt; files_and_content = sc.wholeTextFiles(...);
  </code></pre>
  
  <p>because this way I get a pair of file name and the content.
  However, it seems that this way, the input reader fails to read the text from the gz file, but rather reads the binary Gibberish.</p>
  
  <p>So, I would like to know if I can set it to somehow read the text, or alternatively access the file name using <code>sc.textFile(...)</code></p>