title: How to process multiple files separately after SparkContext.wholeTextFiles?
body: <p>I'm trying to use wholeTextFiles to read all the files names in a folder and process them one-by-one seperately(For example, I'm trying to get the SVD vector of each data set and there are 100 sets in total). The data are saved in .txt files spitted by space and arranged in different lines(like a matrix).</p>
  
  <p>The problem I came across with is that after I use "wholeTextFiles("path with all the text files")", It's really difficult to read and parse the data and I just can't use the method like what I used when reading only one file. The method works fine when I just read one file and it gives me the correct output. Could someone please let me know how to fix it here? Thanks!</p>
  
  <pre><code>public static void main (String[] args) {
      SparkConf sparkConf = new SparkConf().setAppName("whole text files").setMaster("local[2]").set("spark.executor.memory","1g");;
      JavaSparkContext jsc = new JavaSparkContext(sparkConf);
      JavaPairRDD&lt;String, String&gt; fileNameContentsRDD = jsc.wholeTextFiles("/Users/peng/FMRITest/regionOutput/");
  
      JavaRDD&lt;String[]&gt; lineCounts = fileNameContentsRDD.map(new Function&lt;Tuple2&lt;String, String&gt;, String[]&gt;() {
          @Override
          public String[] call(Tuple2&lt;String, String&gt; fileNameContent) throws Exception {
                  String content = fileNameContent._2();
                  String[] sarray = content .split(" ");
                  double[] values = new double[sarray.length];
                  for (int i = 0; i&lt; sarray.length; i++){
                      values[i] = Double.parseDouble(sarray[i]);
                  }
  
  
              pd.cache();
              RowMatrix mat = new RowMatrix(pd.rdd());
  
              SingularValueDecomposition&lt;RowMatrix, Matrix&gt; svd = mat.computeSVD(84, true, 1.0E-9d);
              Vector s = svd.s();
      }});
  </code></pre>