title: How to check for empty RDD in PySpark
body: <p></p>
  
  <pre><code>tweetStream.foreachRDD((rdd, time) =&gt; {
    val count = rdd.count()
    if (count &gt; 0) {
      var fileName =  outputDirectory + "/tweets_" + time.milliseconds.toString    
      val outputRDD = rdd.repartition(partitionsEachInterval) 
      outputRDD.saveAsTextFile(fileName) 
  }
  </code></pre>
  
  <p>I am trying to check count value or empty RDD in stream data in python way , hardy finding ways, also tried examples from the below link.
  <a href="http://spark.apache.org/docs/latest/streaming-programming-guide.html" rel="nofollow noreferrer">http://spark.apache.org/docs/latest/streaming-programming-guide.html</a></p>