How to remove brackets from RDD output?
<p>When I print an RDD I get the following result:</p>

<pre><code>[(46, u'15910'), (43, u'15287'), (43, u'15237'), (42, u'15923'), (41, u'15298')]
</code></pre>

<p>I want to save the RDD output to a csv file without brackets or the 'u' sign, similar to below:</p>

<pre><code>46, 15910
43, 15287
43, 15237
42, 15923
41, 15298
</code></pre>

<p>Either write csv:</p>

<pre><code>&gt;&gt;&gt; rdd.toDF().write.csv("path")
</code></pre>

<p>or format:</p>

<pre><code>&gt;&gt;&gt; rdd.map(lambda (k, v): "{0},{1}".format(k, v)).saveAsTextFile("path")
</code></pre>

python apache-spark pyspark rdd