title: add filename to RDD rows on wholeTextFiles
body: <p>I've been googling and trying this for a couple of hours with no luck, hope any of you can provide advice.</p>
  
  <p>I'm reading a large number of files into a Spark RDD, and I want to append the filename, which contains a timestamp, into each of the rows of the RDD. So far this is what I got.</p>
  
  <pre><code>def append_name(x):
      filename = x[0].split('\n') #take the filename
      content = x[1].split('\n') #take the content
      output = [(row.split(','), filename) for row in content]
      flattened = [item for sublist in output for item in sublist]
      return flattened
  
  data_file = sc.wholeTextFiles("data/").flatMap(lambda l: append_name(l))
  
  data_file.take(1)
  </code></pre>
  
  <p>My output looks like this:</p>
  
  <pre><code>[[u'25689119206459',
    u'True',
    u'3',
    u'main',
    u'used_car',
    u'Huzhou',
    u'False',
    u'False',
    u'21824706815494',
    u'0',
    u'http://jump.zhineng.58.com/clk?target=mv7V0A-b5HTh',
    u'0\r'],
   [u'file:/home/user/data/light_2016-06-01T04-02-27_node1.csv']]
  </code></pre>
  
  <p>Which is still a list of lists... even when I have flattened it. Any ideas of what I'm missing? I also tried using the solution proposed <a href="https://stackoverflow.com/questions/31734760/append-filename-to-rdd">here</a> and got the same results.</p>
  
  <p>Thanks.</p>